Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Joomla component not appearing in the menu item types

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 !!

like image 297
ubi Avatar asked Dec 29 '11 20:12

ubi


2 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!

like image 73
alghimo Avatar answered Nov 02 '22 08:11

alghimo


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

like image 20
Ivar Avatar answered Nov 02 '22 08:11

Ivar