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.

 

Display on K2 item pages for specific category

Display on K2 item pages for specific category

Hi

How do I display Module on all K2 item pages for a specific category?

I searched for for K2 and found this:
if ($content == "com_k2" and $view == "itemlist" ) return XXX; // on itemlist page

but not entirely sure how to edit so my module shows on only item (article) pages for a specific K2 category. 

This is the exact page/category I want it displayed on:
http://www.vacationandcuisine.com/index … ;Itemid=30

Happy to donate again for your help, really love Metamod and the service you provide smile

p.s. would it be useful to include some standard K2 recipes on your recipe page as K2 is a widely used component and I'm sure if more of their community knew Metamod was available and the great flexibility/options it provides I'm sure more would use it.


Joomla 1.5.18
MetaMod 2.5
SOBI 2.9.3.1

Thanks

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Re: Display on K2 item pages for specific category

Hi,

Try this:

if ($option == "com_k2" and $view == "item") {
  $db->setQuery( "select catid from #__k2_items where id = " . ( (int) $id ) );
  $catid = $db->loadResult();
  if ( $catid == XXX ) return YYY ; // for category XXX, use module YYY
}

Replace XXX and YYY as appropriate for your site.

You're right, I need to include some more K2 recipes... problem is there are so many components to do. I'm working on JomSocial at the moment, and SOBI2 and others are on the horizon.

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: Display on K2 item pages for specific category

Hi

Thank you so, so, so much, that worked for me but it only seems to work for child categories, if I choose a parent category then it does not pick up the categories underneath it - does that mean I must include each child category individually?  Do I just copy and paste the code (for how many categories I want) and replace the XXX with each category I need?

Also the module does not retain the styling. For example you can compare the "Similar Tours" section on these pages:

Correct way it should look:
http://www.vacationandcuisine.com/index … ;Itemid=24


How it looks with Metamod:
http://www.vacationandcuisine.com/index … ;Itemid=30

I tried adding the same Module Class Suffix to metamod module and also tried changing the options in "Style for included modules" but no joy, does that mean I need the Pro version? 

FYI - the module I am trying to show is mod_sobi2simplefeatured.

Thank you smile

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Re: Display on K2 item pages for specific category

Hi,

Styling: you tried the right things - all that's left now is the Pro version. I'll give you your money back if it doesn't work... but it should smile

Parent categories: yes, the code only picks up the direct category that something is in. I can make you some code to pick up parents too. How many levels deep does it need to be able to search? (i.e. how many levels deep is your hierarchy?)

If you don't want to wait for that, then you can just add more lines like this:

  ...
  if ( $catid == XXX ) return YYY ; // for category XXX, use module YYY
  if ( $catid == A ) return X ; // for category A, use module X
  if ( $catid == B ) return Y ; // for category B, use module Y
  if ( $catid == C ) return Z ; // for category C, use module Z
}

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: Display on K2 item pages for specific category

Thanks I have 2 levels of categories.

I purchased pro version, I have installed plugin and published it but do I need to do anything else as nothing has changed.

Link: http://www.vacationandcuisine.com/index … ;Itemid=30

Thanks

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Re: Display on K2 item pages for specific category

I had a look at the HTML that is being produced on that page - the Pro version definitely made things look more like the original one that you sent. However the eventual output is still wrong. I wonder if the CSS file isn't being included... will check on that.

I'll have a recipe that checks all the parent categories for you by Monday.

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: Display on K2 item pages for specific category

Ok, about the CSS, it appears that for some reason the SOBI2 CSS file is not being included into the page when it should. Why that's happening I don't know. It's very unusual behaviour.

So you can either add this line into the HEAD section of the index.php file of your template:

  <link rel="stylesheet" href="http://www.vacationandcuisine.com/compo … .css" type="text/css" />

Or you can add this into the MetaMod, so that the MetaMod only adds it to the page when it knows it's including the module: (see the 2 new lines with $document)

if ($option == "com_k2" and $view == "item") {
  $document =& JFactory::getDocument();
  $document->addStyleSheet( JURI::root(true).'/components/com_sobi2/includes/com_sobi2.css' );
  $db->setQuery( "select catid from #__k2_items where id = " . ( (int) $id ) );
  $catid = $db->loadResult();
  if ( $catid == XXX )  return YYY ; // for category XXX, use module YYY
  // etc...
}

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: Display on K2 item pages for specific category

Thank you VERY much, your service is really excellent.  I just submitted a great review to JED for you.

Big, Big Thanks again

and again thanks smile

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Re: Display on K2 item pages for specific category

Thanks for the lovely review smile

Here's the PHP code for checking for K2 categories including parent categories, up to 3 levels deep:

Code:

if ($option == "com_k2" and $view == "item") {

  $query = "select c1.id as id1, c2.id as id2, c3.id as id3 from #__k2_items i
    left join #__k2_categories c1 on i.catid = c1.id
    left join #__k2_categories c2 on c1.parent = c2.id
    left join #__k2_categories c3 on c2.parent = c3.id
    where i.id =  " . ( (int) $id ) ;
  $db->setQuery( $query );
  $catids = $db->loadRow();
  if ( is_array( $catids ) ) {
    if ( in_array( 2, $catids ) ) return XXX; // check for cat 2...
    if ( in_array( 3, $catids ) ) return YYY; // check for cat 3...
    if ( in_array( 4, $catids ) ) return ZZZ; // check for cat 4...
   // etc...
  }
}

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

Re: Display on K2 item pages for specific category

Thank you very much for that.  I also wondered pretty please what the recipe would be for showing:

- only on all K2 category pages (i.e. not on item pages)
- only on specific K2 category pages (again not on item pages)

Thanks again for a wonderful module and great support smile

kaizagency
Beginner Modder
ranks
useravatar
Offline
13 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1685
Total Polls:
6
Total Posts:
5940
Total Posts Today:
1
User Info:
 
Total Users:
5186
Newest User:
Totosite
Members Online:
0
Guests Online:
142

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