Joomla Coding Tips

In Joomla 4, you can disable FrontEnd Module editing via...

Global Configuration > Site > Frontend Editing

 

joomla module noedit

 

 

 

This FAQ was written for Developers of Joomla (not intended for general users).

During the Joomla 2.5 to 3.0 upgrade some functions have changed...

DS Removed

Replace DS with "/". For example:

require_once (dirname(__FILE__).DS.'helper.php');

Becomes...

require_once (dirname(__FILE__).'/helper.php');

JModel, JView and JController

Due to upcoming changes to the MVC implementation in the platform, JModel, JView, and JController are re-used as the names of the new interfaces. For now, use JModelLegacy, JViewLegacy and JControllerLegacy instead.

  • JModel becomes JModelLegacy
  • JView becomes JViewLegacy
  • JController becomes JControllerLegacy

For example:

$controller = JController::getInstance('ComponentName');

becomes

$controller = JControllerLegacy::getInstance('ComponentName');

And...

class ComponentNameController extends JController

becomes...

class ComponentNameController extends JControllerLegacy

Manifest XML Change

Use of the <install> base tag (from 1.5) is no longer supported; use <extension> instead

JUtility getToken obsolete

JSession::getFormToken();

replaces...

JUtility::getToken();

More Info:

Backward Compatibilty list: https://docs.joomla.org/Potential_backward_compatibility_issues_in_Joomla_3.0_and_Joomla_Platform_12.1

 

Module Save Problem

After upgrading from Joomla 2.5 to Joomla 3.0, modules would then not save their changes.

Cause:

Old Cache.

Solution:

Clear the browser cache.

By default Joomla will show a publuished for articles in this format...

Published on Wednesday, 19 March 2014 12:56

To change this format, you need to update the Language file. Joomla 2.5 makes this easy to do from the backend...

In the backend, go to Extensions -> Languagemanager -> Overrides.

Language Constant:DATE_FORMAT_LC2

Text (Default):l, d F Y H:i

Text (New):d F Y

See http://php.net/manual/en/function.date.php for date formats.

To remove the "Published on" bit, add a new Override

Language Constant:COM_CONTENT_PUBLISHED_DATE_ON

Text (Default): Published on %s

Text (New): %s

The resulting date should become...

19 March 2014

 

If you are getting this error...

Warning: Creating default object from empty value in /home/user/public_html/modules/mod_random_image/helper.php on line 85

.. then it could be that php on your server was upgraded from 5.3 to a newer version. From 5.4 onwards they tightened up the rules.

To rectify - you need to define your new object before you start using it.

In the code, above the line one stated in the error message (Line 84), add...

$images[$i] = new stdclass();

 

Or for Event List (line 164)...

$this->_event = new stdClass;

Menu Order Problem

For some of our Joomla 2.5 sites, the menu order changed by itself (possibly after a secuity update). We started seeing this problem around Nov 2013, particularly with sites that were upgraded from Joomla 1.5

Cause:

Joomla 2.5.16 gets confused when the "order" record is filled out in the "_menu" table in the Joomla database.

Solution:

To fix required knowledge of SQL. You will need to edit the joomla database manually using phpMyAdmin, or SSH in and use SQL.

We need make the "order" record = 0 for every menu item. This is the SQL command to execute...

UPDATE `joomla_database`.`prefix_menu` SET `ordering` = '0'

Where 'joomla_database' is the joomla database name, and 'prefix_menu' is your joomla _menu table name. These names are different depening on your installation.

ACY Bulk Mailing Cron Job

To save ongoing cost, create your own cron job.

The page to execute is

http://www.yourdomain.com.au/index.php?option=com_acymailing&ctrl=cron

You can do this will the cron command...

wget -O /dev/null "http://www.yourdomain.com/index.php?option=com_acymailing&ctrl=cron" >/dev/null 2>&1

For HTTPS sites, run this cron command...

wget --no-check-certificate -O /dev/null "https://www.yourdomain.com/index.php?option=com_acymailing&ctrl=cron" >/dev/null 2>&1

Run this, say, every 15min.


Noobs can create a cron job via the cPanel interface - "Cron Jobs".

More info:

http://www.acyba.com/en/support/documentation/129-acymailing-cron-task.html

ACY Mailing Warning

If you are using an old version of ACY mailing and cannot afford upgrading, you might end up getting this error..

acymailing Warning: array_merge() [function.array-merge]:
Argument #2 is not an array in
/home/yourdomain.com.au/public_html/administrator/components
/com_acymailing/helpers/cron.php on line 108

It is due to a php4 to php5 upgrade on your server. The Function array_merge used to accept non-array arguments in PHP4 - but now in PHP5 it does not.

An easy fix is to use the (array) typecaster...

So on line 108:

$this->detailMessages = array_merge($this->detailMessages,$bounceClass->messages);

Becomes

$this->detailMessages = array_merge((array)$this->detailMessages,(array)$bounceClass->messages);

More info here...

http://us3.php.net/manual/en/function.array-merge.php