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.

 

don't want to show modules on article view, how to do it ?

don't want to show modules on article view, how to do it ?

hi
i created a menu link " bollywood " with type as " section / blog -- bollywood " and put the values of : # Leading
# Intro
Columns
# Links as 0, since i don't want to show any articles there but only modules. so now i put some modules the normal way and it showed up great.
but when i go to an article under the bollywood section, also then the module shows up. i don't want the module to show up when i view the article but when i only click the bollywood tab in the menu.

u can see the problem at www.delon.in
go to bollywood - everything's ok
go to any article - you'll see the modules ( Latest Movie Reviews and Previews " ) while the article is also shown, i don't want that.

how can i avoid that.

thanks in advance

dhruvarora22
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: don't want to show modules on article view, how to do it ?

Hi dhruvarora22,

that's pretty straight forward:

- assign a MetaMod onto that page with the following recipe:

Code:

if ($option == "com_content" && $view == "category") return "101,102";

That's assuming that you are returning 2 modules with id 101 and id 102 into the same module position. If they are in different module positions then you need 1 MetaMod per module position, and returning the relevant module in each one.

Hope that helps,
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: don't want to show modules on article view, how to do it ?

thanks a ton dude, i love this module. u guys rock. long live metamod.
i did almost what you did the only problem was that my logic was incorrect i tried to not publish on the article instead of more easier of only publishing at the section page.
and also there were some syntax errors.
nyways thanks.

dhruvarora22
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: don't want to show modules on article view, how to do it ?

metamodguy wrote:

Hi dhruvarora22,

that's pretty straight forward:

- assign a MetaMod onto that page with the following recipe:

Code:

if ($option == "com_content" && $view == "category") return "101,102";

That's assuming that you are returning 2 modules with id 101 and id 102 into the same module position. If they are in different module positions then you need 1 MetaMod per module position, and returning the relevant module in each one.

Hope that helps,
Stephen

I'd like to do opposite of this, having the module only appear within the article layout, so would I achieve this by doing the following?

Code:

if ($option == "com_content" && $view == "article") return "101,102";

I'd also like to have different modules in different category>articles, can I specify the different modules displayed within the article pages of different categories?

ie.

module 1 shown in all articles of category 1 but not in the category view
module 2 shown in all articles of category 2 but not in the category view

underclass
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: don't want to show modules on article view, how to do it ?

Yes, you can do that with a slight change to the "Category" recipe on the recipes page.

Let me see... ok, this variation on the main recipe will ONLY show on article view pages, not on the category list/blog pages.

Code:

$category_id = null;

if ( $option == "com_content" && $view == "article" ) {
  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 ) {
   /* 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 == 1) return 55;/* on category 1, return module 55 */
if ($category_id == 2) return 56;/* on category 2, return module 56 */
if ($category_id == 3) return 57;/* on category 3, return module 57 */
return 50; /* default if nothing else matches */

Hope that helps,
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: don't want to show modules on article view, how to do it ?

Hi Stephen,

I tired your solution above and it worked for articles, displayed the right module id based on the category id. But the problem was with the category view. Instead of not seeing the module (the expected behavior) I kept getting an [error loading module] on the category page. Do you know what might be causing this error? Thanks a ton.

eltahur
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: don't want to show modules on article view, how to do it ?

oops, never mind. I know now why i was getting that error. I failed to specify a correct module id if nothing matched (last line of code). Thanks.

eltahur
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: don't want to show modules on article view, how to do it ?

Yep, you have to make sure that the module IDs that you supply are correct. Theoretically I could get MetaMod to double check all the module ids before it used them, but this would just add extra load on the database, so I decided not to do that in the interests of site speed.

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

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
4
User Info:
 
Total Users:
4378
Newest User:
miller2341
Members Online:
0
Guests Online:
87

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