Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.



Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.


Hide module - Error loading modules

Hide module - Error loading modules


I would like to hide a module when a certain article i viewed in the main window. I found this PHP-code in the recipes-section:

$category_id = null;
if ( $option == "com_content" ) {
  if ( $view == "category" ) {
   /* category list pages (blog or list style) */
   $category_id = (int)$id;
  } else if (array_key_exists("catid",$_REQUEST)) {
   /* if the category id is in the URL */
   $category_id = (int)JRequest::getInt("catid",0);
  if ( $category_id === null && $view == "article" ) {
   /* if it's an article page without the catid mentioned in the url */
   $nullDate = $db->Quote( $db->getNullDate() );
   $my_id = $db->Quote( $db->getEscaped( (int)$id ) );
   $jnow  =& JFactory::getDate();
   $now    = $db->Quote( $db->getEscaped( $jnow->toMySQL() ) );
   $query = "SELECT  title,  id,  catid "
       . " FROM #__content WHERE id = $my_id AND state = 1"
       . " AND ( publish_up = $nullDate "
       . " OR publish_up <= $now )"
       . " AND ( publish_down = $nullDate "
       . " OR publish_down >= $now  )";
   $db->setQuery( $query, 0, 1 );
   $row = $db->loadObject();
   $category_id = $row->catid;
/* Now customise any of the following rules for your use.
* $category_id will correspond to the category id of the
* article being displayed (if one is being displayed!)

if ($category_id == 35) return 51;/* on category 54, return module 0 */
if ($category_id == 54) return 0;/* on category 54, return module 0 */
return 0; /* default if nothing else matches */

Unfortunantly i also need to fill in "quick module or position or id to include" with the module ID, otherwise I get an "error loading modules" mesage.

Beginner Modder
1 Posts
Administrator has disabled public posting

Re: Hide module - Error loading modules

Hi moddatomas,

if you're getting an error loading modules, then the problem is that you are returning module numbers that don't exist, or are disabled (but you don't have "auto-enable modules" turned on).

For one thing, don't return 0, just do a plain return:

if ($category_id == 35) return 51;/* on category 35, return module 51 */
if ($category_id == 54) return;/* on category 54, return nothing */
return; /* default if nothing else matches */

If module 51 is definitely the right id for the target module, and removing the "0" does not get rid of the error, can you double-check the auto-enabling function? If the target module is disabled, you should set auto-enable to "all" to be on the safe side.

If you've done that and it *still* doesn't work, then try enabling the target module but setting it to a different module position (e.g. right-metamod).

If that still doesn't work, please write back and we'll take it from there.

Best regards,

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

3330 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
Total Topics:
Total Polls:
Total Posts:
Total Posts Today:
User Info:
Total Users:
Newest User:
Members Online:
Guests Online:

There are no members online

Forum Legend:

 New Sticky