Keyword

PHP to return category ID??

  • Zandergraphics
  • Zandergraphics's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 1 month ago #88838 by Zandergraphics
PHP to return category ID?? was created by Zandergraphics
I've been able to get 
< ?php echo "$Itemid";? >

to return the current menu ItemID, but what I would really like to do is return the current item's category from K2. I've tried several pieces of code, including

< ?php echo "$cid";? >
< ?php echo $this->item->category->id; ? >
< ?php echo $this->category->id; ? >
< ?php echo "$this->cid"; ? >
< ?php echo $this->cid; ? >

Is there a way to get the category ID to be inserted into a template CSS claas or as part of a URL?

Maybe I'm missing something....

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #88839 by vtiger
Replied by vtiger on topic PHP to return category ID??
< ?php $this->item->catid; ? >

Regards,
l

Please Log in or Create an account to join the conversation.

  • Zandergraphics
  • Zandergraphics's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 1 month ago #88840 by Zandergraphics
Replied by Zandergraphics on topic PHP to return category ID??
class="background-< ?php $this->item->catid; ? >"

returns

class="background-">

Obviously the spaces are removed in the real code...

I can't seem to figure it out...

Lukas said:< ?php $this->item->catid; ? >
Regards,
l

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #88841 by vtiger
Replied by vtiger on topic PHP to return category ID??
In /sometemplate/item.php it works for me..
Are we talking about item.php template?..

l

Please Log in or Create an account to join the conversation.

  • Zandergraphics
  • Zandergraphics's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 1 month ago #88842 by Zandergraphics
Replied by Zandergraphics on topic PHP to return category ID??
I was trying to put it in the main Joomla template in order to change the page backgrounds based on the category.

I should have been more specific in what template I was talking about.


Lukas said:In /sometemplate/item.php it works for me.. Are we talking about item.php template?..

l

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #88843 by vtiger
Replied by vtiger on topic PHP to return category ID??
Than yes, it can't work just with echo...

Probably you need add to J! template some include like require_once(JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'route.php');
and than write some php function... (something like in helper.php in mod_k2_content...)

l

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago #88844 by jorge
Replied by jorge on topic PHP to return category ID??
mmm i hope...

 

< ?php echo $this->item->parent; ? >

 

try and comment.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum