4

我只是按照这个视频创建了一个组件。我创建了名为 admin.zip 的组件。在 joomla 3.0 中安装时,我收到以下警告。

警告

JInstaller: :Install: 文件不存在 C:\wamp\www\Content\tmp\install_52009de34a2c1\site\language\en-GB.com_helloworld.ini

JInstaller: :Install: 文件不存在 C:\wamp\www\Content\tmp\install_52009de34a2c1\admin\language\en-GB.com_helloworld.ini

我在组件菜单下获得 helloworld 组件。但是当我点击它时它给了我错误。它应该向我显示 Hello world,如视频所示。

我的 wamppserver 版本是 2.4 并使用 joomla 3.0。

我该如何纠正这个问题

单击 hello world 组件时的错误是这样的

我的 helloworld.xml 文件包含此代码

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="2.5.0" method="upgrade">

    <name>com_helloworld</name>
    <creationDate>November 2009</creationDate>
    <author>David Thorn</author>
    <authorEmail>info@thornwebdesign.org</authorEmail>
    <authorUrl>http://www.example.org</authorUrl>
    <copyright>Copyright Info</copyright>
    <license>License Info</license>
    <version>1.0.0.1</version>
    <description>Description of the Hello World component ...</description>
    <files folder="site">
            <filename>index.html</filename>
            <filename>helloworld.php</filename>
            <filename>controller.php</filename>
            <folder>css</folder>
            <folder>js</folder>
            <folder>views</folder>
            <folder>models</folder>
            <folder>controllers</folder>
            <folder>helpers</folder>
            <folder>language</folder>
        </files>
        <languages folder="site">
                        <language tag="en-GB">language/en-GB.com_helloworld.ini</language>
                        <language tag="en-GB">language/en-GB.com_helloworld.sys.ini</language>
        </languages>    
    <administration>
            <menu>com_helloworld</menu>
            <files folder="admin">
                <filename>index.html</filename>
                <filename>helloworld.php</filename>
                <filename>controller.php</filename>
                <folder>css</folder>
                <folder>js</folder>
                <folder>views</folder>
                <folder>models</folder>
                <folder>controllers</folder>
                <folder>helpers</folder>
                <folder>language</folder>
            </files>
            <languages folder="admin">
                        <language tag="en-GB">language/en-GB.com_helloworld.ini</language>
                        <language tag="en-GB">language/en-GB.com_helloworld.sys.ini</language>
            </languages>            
    </administration>

 </extension>

在我的 helloworld.php 我有这个代码

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import joomla controller library
jimport('joomla.application.component.controller');

// Get an instance of the controller prefixed by HelloWorld
$controller = JController::getInstance('Helloworld');

// Perform the Request task
$input = JFactory::getApplication()->input;
$controller->execute($input->getCmd('task'));

 // Redirect if set by the controller
  $controller->redirect();
  ?>

更新

我在 joomla 2.5 中成功地做到了这一点,但它在最新版本的 joomla 中不起作用。我应该怎么做才能让它在 joomla 3.0 中工作

4

2 回答 2

1

您的 xml 文件路径中缺少 en-GB 子文件夹声明。xml:language/en-GB.com_helloword.sys.ini 而它应该是 language/en-GB/en-GB.helloworld.sys.ini 和路径:language/en-GB/en-GB.helloworld.sys.ini当然,同样的模式也适用于其他语言文件。

*因为您的编辑和源代码包含在内,包括带有更正的完整 xml 代码(文件路径和扩展结束标记)

`

<?xml version="1.0" encoding="utf-8"?>

<name>com_helloworld</name>
<creationDate>November 2009</creationDate>
<author>David Thorn</author>
<authorEmail>info@thornwebdesign.org</authorEmail>
<authorUrl>http://www.example.org</authorUrl>
<copyright>Copyright Info</copyright>
<license>License Info</license>
<version>1.0.0.1</version>
<description>Description of the Hello World component ...</description>
<files folder="site">
        <filename>index.html</filename>
        <filename>helloworld.php</filename>
        <filename>controller.php</filename>
        <folder>css</folder>
        <folder>js</folder>
        <folder>views</folder>
        <folder>models</folder>
        <folder>controllers</folder>
        <folder>helpers</folder>
        <folder>language</folder>
    </files>
    <languages folder="site">
                    <language tag="en-GB">language/en-GB/en-GB.com_helloworld.ini</language>
                    <language tag="en-GB">language/en-GB/en-GB.com_helloworld.sys.ini</language>
    </languages>    
<administration>
        <menu>com_helloworld</menu>
        <files folder="admin">
            <filename>index.html</filename>
            <filename>helloworld.php</filename>
            <filename>controller.php</filename>
            <folder>css</folder>
            <folder>js</folder>
            <folder>views</folder>
            <folder>models</folder>
            <folder>controllers</folder>
            <folder>helpers</folder>
            <folder>language</folder>
        </files>
        <languages folder="admin">
                    <language tag="en-GB">language/en-GB/en-GB.com_helloworld.ini</language>
                    <language tag="en-GB">language/en-GB/en-GB.com_helloworld.sys.ini</language>
        </languages>            
</administration>

`(不能包含扩展的开始和结束标签,由于某种原因它不会被打印,请确保正确包含它们)

对于您的其他问题,您可能需要在 helloworld.php 中导入 joomla 控制器库:

jimport('joomla.application.component.controller');

之后

defined('_JEXEC') or die('Restricted access');

并替换它:

$controller = JController::getInstance('Helloworld');

有了这个:

$controller = JControllerLegacy::getInstance('Helloworld');
于 2013-08-06T12:54:24.450 回答
1

检查您是否已将此代码添加到您的 XML:

<languages>
        <language tag="en-GB" client="site">language/en-GB/en-GB.com_helloworld.ini</language>
        <language tag="en-GB" client="site">language/en-GB/en-GB.com_helloworldt.sys.ini</language>
</languages>

和:

<administration>
... 
    <languages>
            <language tag="en-GB" client="site">language/en-GB/en-GB.com_helloworld.ini</language>
            <language tag="en-GB" client="site">language/en-GB/en-GB.com_helloworld.sys.ini</language>
    </languages>
...
</administration>

并检查文件是否包含在您的安装 ZIP 中 - 在正确的文件夹中,例如:

语言/zh-CN/ ...

请注意,文件的路径可能因您的扩展而异。

于 2013-08-06T09:53:55.670 回答