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

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

问题描述

我刚刚按照joomla教程学习了如何创建完美的" MVC joomla组件.但是,我的问题是我还不知道如何将其分配给菜单.我以为我的组件会在我选择菜单项类型"时显示出来,但是我的组件不在此列表中.我已经在Google上进行了一些研究,但找不到答案...我是否必须创建一个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文件. 如果您有名为"default.php"和"form.php"的模板,则在组件前端部分的templates文件夹内(通常是/components/com_yourcomponent/views/someview/tmpl 之类的东西) ",则可以创建一个"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天全站免登陆