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.

 

Error info under Debug status when show modules on specific articles

Error info under Debug status when show modules on specific articles

Hi, I copied the following code from the recipe to show modules on specific articles:

Code:

if ( $article_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();
   $article_id = $row->id;
}

if ($article_id == 7324 ) return "596,599";
if ($article_id == 7325 ) return "61,619,625";
if ($article_id == 7834 ) return "619,625";
if ($article_id == 7326 ) return 630;

It seems everything works fine. However, when turned on Debug, I got the following error info:

Notice: Undefined variable: article_id in /home/sumsale/public_html/modules/mod_metamod/helper.php(524) : eval()'d code on line 1

Code:

Notice: Undefined variable: article_id in /home/sumsale/public_html/modules/mod_metamod/helper.php(524) : eval()'d code on line 18


Notice: Undefined variable: article_id in /home/sumsale/public_html/modules/mod_metamod/helper.php(524) : eval()'d code on line 19

Notice: Undefined variable: article_id in /home/sumsale/public_html/modules/mod_metamod/helper.php(524) : eval()'d code on line 20

Notice: Undefined variable: article_id in /home/sumsale/public_html/modules/mod_metamod/helper.php(524) : eval()'d code on line 21

I have no idea what is wrong. Could you please give me a hint to fix it?

Thanks

bxwww
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Error info under Debug status when show modules on specific articles

It's quite easy for this to happen when you cut and paste bits of code... Could I suggest a slight modification:

Code:

$article_id = null;

if ( $option == "com_content" and $view == "article" ) {
   /* if it's an article page */
   $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();
   $article_id = $row->id;
}

if ($article_id == 7324 ) return "596,599";
if ($article_id == 7325 ) return "61,619,625";
if ($article_id == 7834 ) return "619,625";
if ($article_id == 7326 ) return 630;

Cheers,
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: Error info under Debug status when show modules on specific articles

Thank you very much for your quick response, Stephen!

bxwww
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Total Posts Today:
2
User Info:
 
Total Users:
4371
Newest User:
kajha63871
Members Online:
1
Guests Online:
139

Online: 
dotcommz

Forum Legend:

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