Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

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

 

Category ID not working

Category ID not working

Hi "Clock" - I had some forum problems over the last couple of days and appear to have lost your post. Can you please repost here?

Sorry for the inconvenience,
Stephen

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

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Re: Category ID not working

No Problem, here is the trouble I am having.

I have two sites, running Meta mod 1.5l pro. I am using the recipe to make modules appear by category.  However when a new content item is added it takes hours for the modules to show up. I've cleaned the cache and turned off the cache and still it takes hours. The Cat ID is not showing up in the URL (I have not been able to figure out why, we are not using SEF) So that means the Metamod has to find the CatID from the DB right?  I have checked the DB and each item has its CatID, but still no modules for hours.

Any ideas? Anything I can do?
Thank you!

$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->getEscaped((int)$id);
   $query = "SELECT  title,  id,  catid "
       . " FROM #__content WHERE id = '$my_id' AND state = 1"
       . " AND ( publish_up = " .  $nullDate
       . " OR publish_up <= CURRENT_TIMESTAMP )"
       . " AND ( publish_down = " . $nullDate
       . " OR publish_down >= CURRENT_TIMESTAMP  )";
   $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 == 3) return 26; /* Company  */
if ($category_id == 4) return 38;/* WEll-being */
if ($category_id == 5) return 39;/* Retailers */
if ($category_id == 6) return 40;/* contact */
if ($category_id == 7) return 63;/* newspress */
if ($category_id == 8) return 64;/* Privacy legal  */
if ($category_id == 9) return 65;/* trade partners */

Clock
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Category ID not working

Hi,

The problem is due to time zone differences between your server and your database, which Joomla normally takes care of automatically. Unfortunately the recipe wasn't taking the same care - it was based on some old Joomla 1.0 code and needed updating.

Take a look at the updated recipe on http://www.metamodpro.com/support/recip … e-category - in particular, these lines which you should change in your recipe too:

Code:

  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->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  )";
  (etc etc)

Please let us know if that works for you now.

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

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Re: Category ID not working

Thanks for the reply!

I tried the new code and it stopped everything from working (on old and new content.)  I have set the server time in Joomla to what the Server should be and still not working.  I have gone back to the older MetaMod to compare.  The older recipe still works on older content, but still not for newer.  I have included metadebug information below. 

From New Recipe on old content
MetaMod debug info:
$option: com_content
$view: article
$id: 4
$Itemid: 2
$timezone: default
$language: en-us
$language_code: en
$language_region: us
Including modules:

From Old Recipe on old content
MetaMod debug info:
$option: com_content
$view: article
$id: 4
$Itemid: 2
$timezone: default
$language: en-us
$language_code: en
$language_region: us
Including modules: 46

Any ideas? I am going to play with the code for a bit more and see if I can come up with something. Thank you!
-C

Clock
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Category ID not working

Oh, I'm so sorry about that - I made a mistake in the code. That'll teach me not to post code before testing it...

Replace this line:

$now      = $db->getEscaped( $jnow->toMySQL() );

with this:

$now      = $db->Quote( $db->getEscaped( $jnow->toMySQL() ) );

That fixes the SQL error, and at least on my installation makes it work.

Best regards,
Stephen

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

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Re: Category ID not working

It works!

You so rock.

Thank you so much!
-Clock

Clock
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
3
User Info:
 
Total Users:
4421
Newest User:
rajajudi14
Members Online:
0
Guests Online:
88

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked