I have two different templates on my site, lets just call them Tcat and Titem. My k2 category view page is using Tcat, that is, the menu item of k2 category view page is associated with Tcat. I want the k2 item pages to use Titem, that is, when I click an item link in the category view page, I hope the new page showing this item will be using Titem. However, by default, this new item page will be using Tcat.
I know this is because there is a "itemid=xxx" parameter in the link href.
As far as I know, a k2 item can be open through URL like mysite.com/index.php?option=com_k2&view=item&id=10
, in this case, with no menu item id in the URL, the page will be using the default template; but if Itemid
parameter is added and the URL looks like http://67.20.67.232/index.php?option=com_k2&view=item&id=10&Itemid=150
, then the page will be using the template associated with #150
menu item. Problem is, since I've associated the category view with #150
menu item, the links of all items in this category seem to always have this Itemid=150
parameter.
I'm always encountering similar problem with k2. One workaround I can think of is using javascript to eliminate that Itemid
parameter, another not so practical way is to associate each item with a menu item that is associated with Titem.... Is there any other way? Maybe by hardcoding some PHP?
Besides, In k2 template php files, the link is generated by something like <?php echo $this->item->link ?>
, I think if I find out how the $this->item
object is conducted, I may find a way to hardcode it. But my PHP knowledge is very limited, upon some researching, I can only get as far as finding out that $this
is an instance of k2ItemviewList
class in com_k2/views/itemlist/view.html.php
, but this class only have one member: function display($tpl = null)
, the item
is nowhere to be found. I am learning PHP and trying to understand joomla core and k2 core, this is why I am not satisfied with javascript solution. If you can explain how to track the codes behind $this->item->link
, that will help a lot with my learning. Any hint is greatly appreciated. Thanks in advance.