Reputation: 83
I want to get the current item id from k2 and store it to a cookie.
(Of course when i wrote "the current item" I am in the item view of my k2 template.)
How can I get the item ID from K2?
I tried $this->item->id
but seems it's not working.
Any ideas?
Thanks!
Upvotes: 0
Views: 3713
Reputation: 7
I agree with @shaz - this worked for me (item.php and category_item.php overrides):
<?php echo $this->item->id; ?>
Upvotes: -2
Reputation: 39
$K2Itemid = JRequest::getInt('id');
$db = JFactory::getDBO();
$db->setQuery("SELECT title FROM #__k2_items WHERE id = ".$K2Itemid );
$K2Catid = $db->loadResult();
echo $K2Catid;
Upvotes: 3
Reputation: 2647
It depends where you are. Is it an item view ? If so, $this->item->id should work. I've done it many times.
Upvotes: 2