|
|
<p>I would like to be able to assign modules to the various tag views.<br /><br />To do this the tags that are linked need to include an Itemid so joomla can select the appropriate modules for that Menu Item..<br /><br />I have created an update to version 1.2.8 that will force the item id of the first "alltags" menu item item finds onto all tags links.<br /><br />This will give me at least one Menu Item that I can assign modules to for use by all the various tag component views.<br /><br />The approach I took was to add the following function to components/com_tag/helper/<strong>helper.php</strong><br /><br /> function getItemidLink(){<br /> $itemid = null;<br /> $component =& JComponentHelper::getComponent('com_tag');<br /> $menus = &JApplication::getMenu('site', array());<br /> $activeMenu = $menus->getActive();<br /> if ($activeMenu->componentid == $component->id) {<br /> $itemid = $activeMenu->id;<br /> } else {<br /> $items = $menus->getItems('componentid', $component->id);<br /> foreach ($items as &$menu) {<br /> if (@$menu->query == 'alltags') { $itemid = $menu->id; break; } } if (!isset($itemid) && count($items)) { $itemid = $items[0]->id;<br /> }<br /> }<br /> return($itemid ? '&Itemid='.$itemid : '');<br /> }<br /><br />And then call that function at every occurance where a link is rendered, for example, in plg_tags_content <br /><br />... near all the other initialization for onPrepareContent so it is only done once ...<br /><br /> $itemidLink = JoomlaTagsHelper::getItemidLink();<br /><br />... then in the foreach $terms loop ...<br /><br /> $link='index.php?option=com_tag&task=tag&tag='.urlencode($term->name)<strong>.$itemidLink</strong>;<br /><br />...<br /><br />Feel free to use these code snippets as is, as a model or not at all.<br /><br />Alternatively we could have parameter settings in the component to assign a menu item to each of the various views.</p> |
IP Logged
|