0

问题是自制模块无法正常工作-我在 Joomla 3.0 中制作了自制模块。我在这里创建了一个mod_products文件夹,我们创建了一个名为mod_products.php的文件。

mod_products.php - 代码

defined('_JEXEC') or die;
require_once __DIR__ . '/helper.php';         
$value = modProductsHelper::getproducts( $params );
require JModuleHelper::getLayoutPath('mod_products', $params->get('layout', 'default'));

之后我制作了第二个文件helper.php代码 -

class modProductsHelper{

    public static function getProducts( $params ){
          return 'Products';
    }

} 

第三个是default.php

<?php      

defined('_JEXEC') or die;

if($value!='') { ?>

<ul style="margin-left: 0px;" class="clients-list slides-list slide-wrapper">
       <li class="slide">
            <div class="product-image"><img src="images/product3.png" width="181" height="177"></div>
       </li>       
</ul>
<?php } ?>

然后我们通过管理员面板安装并给mod_products模块一个位置并显示在index.php文件中,如下所示:

<div class="grid_12 product_home">
    <jdoc:include type="modules" name="position-3" />
</div>

但它没有显示在网站上。有谁知道为什么?

编辑:mod_products.xml

<?xml version="1.0" encoding="utf-8"?> 
<extension type="module" version="3.0" client="site" method="upgrade"> 
    <name>mod_products</name> 
    <author>Joomla! Project</author> 
    <creationDate>July 2004</creationDate> 
    <copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright> 
    <license>GNU General Public License version 2 or later; see LICENSE.txt</license> 
    <authorEmail>admin@joomla.org</authorEmail> 
    <authorUrl>www.joomla.org</authorUrl> 
    <version>3.0.0</version> 
    <description>MOD_PRODUCTS_XML_DESCRIPTION</description>
    <files> 
        <filename module="mod_products">mod_products.php</filename> 
        <folder>tmpl</folder> 
        <filename>helper.php</filename> 
        <filename>mod_products.xml</filename> 
    </files> 
    <config> 
    </config> 
</extension>
4

2 回答 2

1

对,我为你创建了一个小例子。我认为这可能是由于您调用了错误的模块布局,并不完全确定。

这是下载模块的链接。通过 Joomla 后端卸载您正在使用的当前模块并安装它:

http://www.mediafire.com/download/ucp3prv219430zl/mod_products.zip

另外,不要忘记将模块分配给菜单项。这可能是之前的问题

享受

于 2013-11-22T10:21:12.987 回答
0

对我来说,您的问题似乎是模块名称。在某些地方您使用过 mod_product 而在其他地方 mod_products 请确保您只使用一个。我建议您更改

require JModuleHelper::getLayoutPath('mod_products', $params->get('layout', 'default'));

require JModuleHelper::getLayoutPath('mod_product', $params->get('layout', 'default'));

还要检查您是否已发布该模块并针对所有页面进行测试。

于 2013-11-22T10:06:38.203 回答