1

I want to create a custom com_tags/tags layout, however I need to keep the parent_id field for the menu item.

What I have done is create:

/templates/mytemplate/html/com_tags/tags/species.php
/templates/mytemplate/html/com_tags/tags/species.xml (copied from administrator/components/tags/config.xml)

This shows a "Species" entry in the menu type popup, however none of the customisation fields is there anymore. I need the parent_id field, which is on the "List of all tags" entry.

I debugged the code and apparently I need

/templates/mytemplate/html/com_tags/metadata.xml

which seems to need to contain some sort of "menu" entry. I can't find any example of how this should be formatted.

This is an example file from Akeeba backup https://github.com/akeeba/contactus/blob/master/component/frontend/views/item/metadata.xml but I cannot figure out how to add options here?

1

If I understand your question, your trying to create a custom menu type for the com_tags component and need to set the id for the menu item when you create it in the menu manager.

If that is the case you shouldn't copy the config.xml

You should copy

joomlaRoot/components/com_tags/views/tags/default.xml 

which has the fields for parent id, as well as the params defined in it.

Just make sure to change the name to species.xml and change the title/option text so that Joomla knows this is a different layout.

I hope this helps.

  • This was exactly what I am looking for! – jdog Jun 9 '14 at 23:59
  • =^D glad I could help. – Mathew Lenning Jun 10 '14 at 5:15
1

If I am understanding correctly then there is another option, and that is to "ignore" the normal way that is difficult to achieve without some sort of override and use the fact that your override is a php file to get the information separately.

How to get Itemid by URL and pass it to JRoute

My answer here shows the following to create a link to a specific page by getting the menu item ID.

$app = JFactory::getApplication(); 
$menu = $app->getMenu();
$menuItem = $menu->getItems( 'link', 'index.php?option=com_example&view=something', true );
echo JRoute::_('index.php?Itemid='.$menuItem->id);

Now in this case $menuItem is actually an object containing the information about that menu item.

so.....

$app = JFactory::getApplication(); 
$menu = $app->getMenu();
$menuItem = $menu->getItems( 'link', 'index.php?option=com_example&view=something', true );
echo JRoute::_('index.php?Itemid='.$menuItem->parent_id);

Should get you a link to the parent menu item.

But you may just need the current menu item, so by adjusting this line:

$menuItem = $menu->getItems( 'link', 'index.php?option=com_example&view=something', true );

to:

$menuItem = $menu->getActive();

You should be able to get the link of the parent of the current page only. Experimenting can probably take this much further as well as $menu->getItems() has a lot of options you can use (although I have been unable to find a good documentation page on it).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.