简体   繁体   English

我的Joomla组件菜单项在哪里?

[英]Where is my Joomla component menu item?

I am writing my first Joomla component, on Joomla 3.3.0, following the book Learning Joomla! 我正在学习Joomla一书之后,在Joomla 3.3.0上编写我的第一个Joomla组件 3 Extension Development, Third Edition. 3扩展开发,第三版。

I am following the author's advice and writing code directly under Jommla's folders, such as \\administrator\\components\\com_coup , where com_coup is my component for a coupon management system. 我遵循作者的建议,并直接在Jommla的文件夹下编写代码,例如\\administrator\\components\\com_coup ,其中com_coup是我的优惠券管理系统的组件。 I have a full folder structure, and at the end of a chapter the author says I should have a certain folder and file structure, and am ready for installation by Discovery , Joomla finds my component in Site and Administration , and installing the admin one seems to go well, but no menu item is inserted into the Components menu. 我有一个完整的文件夹结构,在本章的最后,作者说我应该有一个特定的文件夹和文件结构,并准备由Discovery安装,Joomla在“ SiteAdministration找到了我的组件,并且似乎安装了一个管理员。进行得很好,但是没有在“ Components菜单中插入任何菜单项。

Should I be discovering two components, why is my menu item not inserted. 我应该发现两个组件,为什么没有插入菜单项。 My `coup.xml' file contains the line: 我的“ coup.xml”文件包含以下行:

<administration>
    <menu img="class:categories">COM_COUP_MENU</menu>

and the text item COM_COUP_MENU exists in the language\\en-GB\\en-GB.com_coup.sys.ini file. language\\en-GB\\en-GB.com_coup.sys.ini文件中存在文本项COM_COUP_MENU

My coup.xml file is: 我的coup.xml文件是:

<?xml version ="1.0" encoding ="utf-8"?>
<extension type="component" version="3.0" method="upgrade">
    <name>com_coup</name>
    <author>Brady Kelly</author>
    <creationDate>2014-06-14</creationDate>
    <copyright>(C) Erisia Web Development. All rights reserved.</copyright>
    <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
    <authorEmail>brady@bradykelly.net</authorEmail>
    <authorUrl>http://thepraxis.co.za/</authorUrl>
    <version>1.0.0</version>
    <description>COM_COUP_XML_DESCRIPTION</description>
    <scriptfile>script.php</scriptfile>
    <install>
        <sql>
            <file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
        </sql>
    </install>
    <uninstall>
        <sql>
            <file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
        </sql>
    </uninstall>
    <files folder="site">
        <filename>index.html</filename>
    </files>
    <administration>
        <menu img="class:categories">COM_COUP_MENU</menu>
        <files folder="admin">
            <filename>index.html</filename>
            <filename>access.xml</filename>
            <filename>config.xml</filename>
            <filename>controller.php</filename>
            <filename>coup.php</filename>
            <folder>controllers</folder>
            <folder>helpers</folder>
            <folder>models</folder>
            <folder>sql</folder>
            <folder>tables</folder>
            <folder>views</folder>
        </files>
        <languages folder="admin">
            <language tag="en-GB">language/en-GB/en-GB.com_coup.ini</language>
            <language tag="en-GB">language/en-GB/en-GB.com_coup.sys.ini</language>
        </languages>
    </administration>
</extension>

and my en-GB.com_coup.sys.ini file is: 我的en-GB.com_coup.sys.ini文件是:

COM_COUP="Coup"
COM_COUP_XML_DESCRIPTION="The winning voucher and coupon manager!"
COM_COUP_MENU="Voucher Coup"

It could be failing in a few different places, the first thing to check is that you have error reporting set to " Development " ( Global Configuration—>Server->Server Settings ) and Debug System turned on ( Global Configuration—>System->Debug Settings ), you may also want to turn on Debug Language (it's just below Debug System ). 它可能在几个不同的地方都失败了,首先要检查的是您已将错误报告设置为“ 开发 ”( Global Configuration—>Server->Server Settings ),并且Debug System打开( Global Configuration—>System->Debug Settings ),您可能还希望启用Debug Language (它位于Debug System下方)。

Stepping through process these are the steps that are happening (you don't mention any errors and a silent failure seems unusual). 逐步执行这些步骤是正在发生的步骤(您没有提到任何错误,并且静默失败似乎很罕见)。

When discover() runs it loads all of the installer/adapater/ 's found in /libraries/cms/ , you've said it's a component, so the component.php adapter is the relevant one. discover()运行时,它将加载在/libraries/cms/找到的所有installer/adapater/ ,您已经说过它是一个组件,因此component.php适配器就是相关的component.php This loops through the site and admin /components/ directories looking for each components xml file (ie your coup.xml ). 这遍历站点和admin /components/目录,以查找每个组件xml文件(即您的coup.xml )。 If there was a problem in your XML file this could cause an error but it would occur before the install step which apparently you can run. 如果XML文件中存在问题,则可能会导致错误,但可能会在安装步骤之前发生,显然您可以运行该步骤。

The fact that your component is found twice might be part of the problem… do you have coup.xml in both the site's /components/com_coup and /administrator/components/com_coup ? 你的组件被发现两次可能是问题的一部分...你有事实coup.xml在这两个网站的/components/com_coup/administrator/components/com_coup (Our extensions only have them in the admin side, I'd probably remove the front end one). (我们的扩展程序仅在管理方面具有它们,我可能会删除前端程序)。

The adapters return an array of found items (components, modules, plugins, libraries etc) this is compared to the extensions registered in #__extensions and any items that aren't listed are added to the extensions table with a state of -1 . 适配器返回找到的项目(组件,模块,插件,库等)的数组,并将其与#__extensions注册的扩展进行比较,未列出的任何项目均以state -1添加到扩展表中。 The "Discover" view then displays the list of items found so the user can select one or more of them and "Install" them. 然后,“发现”视图显示找到的项目列表,以便用户可以选择其中一项或多项并“安装”它们。

discover_install() basically runs a normal install (except the copy files), so it runs any install SQL files. discover_install()基本上运行常规安装(复制文件除外),因此它运行所有安装SQL文件。

Then it runs _buildAdminMenus() to add the Admin menus where it looks to see if the extension already has a menu before over writing it. 然后,它运行_buildAdminMenus()来添加“管理”菜单,在该菜单中,它会在覆盖之前查看扩展名是否已有菜单。

Finally any InstallerScript file found in the manifest is run. 最后,清单中找到的所有InstallerScript文件都将运行。

Each of these stages could throw an error - but you should see an error message of some kind in that case. 每个阶段都可能引发错误-但是在这种情况下,您应该会看到某种错误消息。

I would check: 我会检查:

  1. your XML file validates correctly 您的XML文件正确验证
  2. for Language file errors (shown in the Joomla Debug Console, when Debug Languages is enabled. 语言文件错误(启用Debug Languages ,显示在Joomla调试控制台中)。
  3. check your SQL install files run in a SQL console like SequelPro or phpMyAdmin 检查您的SQL安装文件是否在SequelProphpMyAdmin等SQL控制台中运行
  4. validate your instal script ( php -l /path/to/file.php ) 验证您的安装脚本( php -l /path/to/file.php

Adding your full XML file and sys.ini language file could also help. 添加完整的 XML文件和sys.ini语言文件也可能会有所帮助。 ini language files can be tricky if you haven't been using the Debug Languages option. 如果您从未使用过Debug Languages选项, ini语言文件可能会很棘手。

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

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