简体   繁体   English

Joomla 组件未出现在菜单项类型中

[英]Joomla component not appearing in the menu item types

I just followed the joomla tutorials on how to create the "perfect" MVC joomla component.我只是按照关于如何创建“完美”MVC joomla 组件的 joomla 教程进行操作。 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 ?我在谷歌上做了一些研究,但我找不到答案......我是否必须创建一个 metadata.xml 文件或类似的文件? Thanks in advance for your answers !!预先感谢您的回答!!

To create "views" for your component, you have to create some xml files.要为您的组件创建“视图”,您必须创建一些 xml 文件。 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.在组件前端部分的模板文件夹内(通常类似于/components/com_yourcomponent/views/someview/tmpl ),如果您有一个名为default.phpform.php的模板,您可以创建一个default.xml文件和一个form.xml文件,使管理员可以使用这些菜单项。 You can take a look at other components to see the structure of these xml files, but what you should put inside is:可以看看其他组件,看看这些xml文件的结构,但是里面应该放的是:

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. 1) 四个视图的名称和描述 2) 用户可以从管理员那里更改的参数(它的工作方式类似于模块/插件参数) 3) 您还可以为该菜单项设置“隐藏”请求变量。 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):这是一个组件的完整示例(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/如果您只是想将视图链接添加到列表中,请在 com_yourcomponent/views/yourviewname/tmpl/ 中创建一个名为 default.xml 的 xml 文件

The xml code below takes two language strings used to display your menu item link in the list下面的 xml 代码采用两种语言字符串,用于在列表中显示您的菜单项链接

<?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.显然,您还需要安装 XML 文件中的管理菜单标签。 http://forum.joomla.org/viewtopic.php?p=706714 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认为这就是 Panayiotis 想说的

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.我已经浪费了一个小时来揭示一个问题。

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.在组件的安装 XML 文件的部分中,标签必须存在,即使您不需要菜单。

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 :-)如果缺少这些,那么您将永远无法选择将此组件添加到菜单项中,因为类型不会存在:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM