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.

 

Recipe Request: Mod only on Article Page

Recipe Request: Mod only on Article Page

Hi there,

I think this module is exactly what I need. I purchased the pro version thinking it would get rid empty modules on my sections and categories pages. My site is quite large and I have a mod that will show related items on the article pages, however it will show up as just a title on my section and category pages. I know I can mess with hidden menus and create a link for every page... however with over 2000 pages this is quite a problem.

SO I am looking for a recipe where the mod only shows on the article page, HOWEVER the menu item selected should be the section. Maybe there is an easier way to do this that I am missing, if so please suggest.

Specifically:

1.From the Module Window, I want to be able to select specific sections (27 to be exact)
2.The Section and Categories are then bypassed of this Module.
3.The module then appears on articles of the 27 specific sections.

Thanks again!

I really love this software.

Ty

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

Re: Recipe Request: Mod only on Article Page

Hi Ty,

I'm not sure what you mean by your 2nd paragraph. "... However the menu item selected should be the section".

It's very easy to make sure that the module does not show up on Section and Category pages, only on the article pages. Are you saying that you simply only want this to happen on articles that are in a category that's in 1 of 27 specified sections?

If so, here's what I would do:

Code:

if ($option == "com_content" and $view == "article" ) {

  $selected_sections = array (2,4,6,8,10,11,12,... and all the rest of your 27 sections);
  $article_id = (int)$id;
  $nullDate = $db->Quote( $db->getNullDate() );
  $jnow  =& JFactory::getDate();
  $now    = $db->Quote( $db->getEscaped( $jnow->toMySQL() ) );

  $query = "select sectionid from #__content where state = 1 AND id = $article_id "
       . " AND ( publish_up = $nullDate "
       . " OR publish_up <= $now )"
       . " AND ( publish_down = $nullDate "
       . " OR publish_down >= $now  ) ";

  $db->setQuery( $query, 0, 1 );
  $row = $db->loadObject();
  $sectionid = (int)@$row->sectionid;

  if ( in_array( $sectionid, $selected_sections) ) return XXX;
  // replace XXX with module id to show, when an article from one of the selected sections is displayed.
}

Tested it out, seems to work fine for me.

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Recipe Request: Mod only on Article Page

Hi Stephen,

Thank you for your work! I applied the recipe, and changed the sections to match mine, however I am getting an error. I turn debug on

MetaMod debug info:
$option: com_content
$view: article
$id: 11
$Itemid: 18
$timezone: default
$language: en-us
$language_code: en
$language_region: us

Parse error: syntax error, unexpected $end in /nfs/c03/h03/mnt/55998/domains/start.careerleak.com/html/modules/mod_metamod/helper.php(523) : eval()'d code on line 1
Including modules: 51

I currently have the mod on a test domain: http://start.careerleak.com/company-a/

Also, I am running the latest Joomla, I have a Yootheme template.

Am I missing something?

Thank you for your help!

Ty

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

Re: Recipe Request: Mod only on Article Page

Solved.... It looks like some additional conditions were affecting this code.. It works perfect now! Thank you!!!!

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

Re: Recipe Request: Mod only on Article Page

Thanks for letting me know it's working. Any time you get an error like this that ends with "... eval()'d code on line XX", that means that there's some error in your PHP code. It even gives the line # where it thinks the error is... very handy. Sometimes the error is in the line before the one it says, but it's usually a good guide for where to look.

I actually think this is a very cool recipe, and allows you to show a "check back soon..." message on pages where they would otherwise be empty. Nice.

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Recipe Request: Mod only on Article Page

Hey Stephen,

Thanks for all of your help. The Recipe is working perfectly except, as I am using this as a related articles modules, when there are NO related articles I am stuck with a blank module. Is there an addition to the code we could add to prevent it from showing on an article that does not have any related articles?

Thanks!

Ty

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

Re: Recipe Request: Mod only on Article Page

The only way to do this at the moment would be to basically recreate the check for related articles, and put that check inside the MetaMod rule, and use it when deciding whether or not to show the module.

You're making me think about whether MetaMod should be able to pre-render modules too... that would be quite useful, as MetaMod could then decide whether or not to show a module based on how it rendering. Interesting possibility... but no promises for the next couple of months at least.

To proceed from here: you would need to dissect the related articles module and see if you can find some good code to put inside the MetaMod.

Sorry there's not an easy answer to this.

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Recipe Request: Mod only on Article Page

Ok.... Thanks Stephen. I love the mod as is.... I will love forward to any updates you may have in the future.

TY

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

Board Info

Board Stats:
 
Total Topics:
1689
Total Polls:
6
Total Posts:
5941
Posts this week:
1
User Info:
 
Total Users:
5355
Newest User:
titus87954
Members Online:
3
Guests Online:
110


Forum Legend:

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