Joomla 组件未出现在菜单项类型中 [英] Joomla component not appearing in the menu item types

查看:32
本文介绍了Joomla 组件未出现在菜单项类型中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚学习了关于如何创建完美"MVC joomla 组件的 joomla 教程.但是,我的问题是我还不知道如何将它分配给菜单.我以为我的组件会在我选择菜单项类型"时显示,但我的组件不在此列表中.我对谷歌做了一些研究,但我找不到答案......我是否必须创建一个 metadata.xml 文件或类似的文件?提前感谢您的回答!!

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

推荐答案

要为组件创建视图",您必须创建一些 xml 文件.在组件前端部分的模板文件夹内(通常类似于 /components/com_yourcomponent/views/someview/tmpl),如果您有一个名为 default.php 的模板和 form.php,您可以创建一个 default.xml 文件和一个 form.xml 文件,以使管理员可以使用这些菜单项.可以看看其他组件,看看这些xml文件的结构,但是里面应该放的是:

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) 四视图的名称和描述2) 用户可以从管理员那里更改的参数(它的工作原理类似于模块/插件参数)3) 您还可以为该菜单项设置隐藏"请求变量.这意味着这些变量将被添加到该特定菜单项中的请求中,但用户将无法更改其值.

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.

这是一个完整的组件示例(Joomla 1.7):

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>

希望能帮到你!

这篇关于Joomla 组件未出现在菜单项类型中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆