I just followed the joomla tutorials on how to create the "perfect" MVC joomla component. However, my problem is that I don't know yet how to assign it to a menu. I thought that my component would then just show up when I select a "menu item type", but my component is not on this list. I've made some research on Google, but I cannot find the answer... Do I have to create a metadata.xml file or something similar ?
Thanks in advance for your answers !!
To create "views" for your component, you have to create some xml files. Inside the templates folder in the frontend part of your component (usually something like /components/com_yourcomponent/views/someview/tmpl), if you had a template named "default.php" and "form.php", you can create a "default.xml" file and a "form.xml" file to make these menu items available from the administrator. You can take a look at other components to see the structure of these xml files, but what you should put inside is:
1) A name and a description for four view 2) The params the user will be able to change from the administrator (it works like module/plugin params) 3) You can also set "hidden" request variables for that menu item. It means that those vars will be added to the request in that particular menu item, but the user won't be able to change its value.
Here's a complete example for a component (Joomla 1.7):
<?xml version="1.0" encoding="utf-8"?> <metadata> <layout title="COM_AGMTAGS_TAG_VIEW_DEFAULT_TITLE"> <message>COM_AGMTAGS_TAG_VIEW_DEFAULT_DESC</message> </layout> <fields name="request" addfieldpath="/administrator/components/com_agmtags/models/fields"> <fieldset name="request"> <field name="tag_id" type="agmtag" label="COM_AGMTAGS_TAG_FIELD_NAME_LABEL" description="COM_AGMTAGS_TAG_FIELD_NAME_DESC" /> </fieldset> </fields> <fields name="params"> <fieldset name="basic" label="COM_AGMTAGS_TAG_OPTIONS"> <field name="layout_type" type="hidden" default="blog" /> <field name="show_tag_name" type="list" label="COM_AGMTAGS_SHOW_TAG_NAME" description="COM_AGMTAGS_SHOW_TAG_NAME_DESC" > <option value="">JGLOBAL_USE_GLOBAL</option> <option value="0">JHIDE</option> <option value="1">JSHOW</option> </field> <field name="show_tag_description" type="list" description="COM_AGMTAGS_SHOW_TAG_DESCRIPTION_DESC" label="COM_AGMTAGS_SHOW_TAG_DESCRIPTION_LABEL" > <option value="">JGLOBAL_USE_GLOBAL</option> <option value="0">JHIDE</option> <option value="1">JSHOW</option> </field> <field name="items_per_page" type="text" default="" /> <field name="container_class" type="text" default="agmtags-list" /> </fieldset> </fields> </metadata>
I hope it helped!
If you simply want to add the view link to the list create a xml file called default.xml inside the com_yourcomponent/views/yourviewname/tmpl/
The xml code below takes two language strings used to display your menu item link in the list
<?xml version="1.0" encoding="utf-8"?> <metadata> <layout title="COM_YOURCOMPONENT_FRONPAGE_TITLE"> <message>COM_YOURCOMPONENT_FRONPAGE_MSG</message> </layout> </metadata>
save the file and the link should appear in the list of menu items
Apparently, you also need the administration menu tags in your installation XML file. http://forum.joomla.org/viewtopic.php?p=706714
This worked for me
<administration> <menu>COM_COMPONET</menu> <submenu> etc... </submenu>
Think this is what Panayiotis was trying to say
Additionally there is also another catch. In the installation XML file of the component, in the section, the tags must be present, even if you do not need the menu.
If these are missing, then you'll never be given the option to add this component to a menu item, because the type wont be there :-)
In additional, your alternative view file names MUST NOT be written with underscores.
table_catalog.xml table_catalog.php table_catalog_item.php
didn't work - there wasn't new option in "menu item type" list. But
tablecatalog.xml tablecatalog.php tablecatalog_item.php
file names work perfectly. I've lost an hour revealing a problem.