0

我试图在 mod_virtuemart_product 模块中安装我的模块以进行实时搜索。我以这种方式更改了 mod_virtuemart_product.xml:

旧代码

<install type="module" version="1.5.0">
    <name>mod_virtuemart_product</name>
    <creationDate>March 17 2013</creationDate>
    <author>The VirtueMart Development Team</author>
    <authorUrl>http://www.virtuemart.net</authorUrl>
    <copyright>Copyright (C) 2004-2012 Virtuemart Team. All rights reserved.</copyright>
    <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
    <version>2.0.20b</version>
    <description>MOD_VIRTUEMART_PRODUCT_DESC</description>
    <files>
    <filename module="mod_virtuemart_product">mod_virtuemart_product.php</filename>
    <filename>index.html</filename>
    <filename>helper.php</filename>
    <filename>tmpl/default.php</filename>
    <filename>tmpl/default2.php</filename>
    <filename>tmpl/default3.php</filename>
    <filename>tmpl/index.html</filename>
    </files>
    <params addpath="/administrator/components/com_virtuemart/elements">
    <param  name="layout" type="filelist" label="MOD_VIRTUEMART_PRODUCT_LAYOUT"
                description="MOD_VIRTUEMART_PRODUCT_LAYOUT_DESC"
                directory="/modules/mod_virtuemart_product/tmpl"
                default="default" hide_default="1" hide_none="1"
                stripext="1" filter="\.php$" exclude="^_" />
.
.
.

新代码

<extension type="module" version="2.5" method="upgrade">
    <name>mod_virtuemart_product</name>
    <creationDate>March 17 2013</creationDate>
    <author>The VirtueMart Development Team</author>
    <authorUrl>http://www.virtuemart.net</authorUrl>
    <copyright>Copyright (C) 2004-2012 Virtuemart Team. All rights reserved.</copyright>
    <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
    <version>2.0.20b</version>
    <description>MOD_VIRTUEMART_PRODUCT_DESC</description>
    <files>
    <filename module="mod_virtuemart_product">mod_virtuemart_product.php</filename>
    <filename>index.html</filename>
    <filename>helper.php</filename>
    <filename>tmpl/default.php</filename>
    <filename>tmpl/index.html</filename>
    <filename>tmpl/quicksearch.php</filename>

    </files>
    <params addpath="/administrator/components/com_virtuemart/elements">
.
.
.

我以这种方式在 mod_virtuemart_product/tmpl 文件夹中创建了新的 php 文件和 javascript 文件:

我以这种方式在 mod_virtuemart_product/tmpl 文件夹中创建了新的 php 文件和 javascript 文件:

mod_virtuemart_product/tmpl/quicksearch.php
mod_virtuemart_product/tmpl/default.php - used by virtuemart (I just add to this code 
my search input code)
mod_virtuemart_product/tmpl/head.php
mod_virtuemart_product/tmpl/config.php
mod_virtuemart_product/tmpl/js/javascript.js
mod_virtuemart_product/tmpl/css/css.css

一切都是相连的。我的代码可以正常工作,但是当我想将此代码添加到我的 quicksearch.php 文件时: echo mod_virtuemart_product::addtocart ($product);

它给我写了这个错误:

“致命错误:在第 34 行的 /www/t/r/u46223/public_html/modules/mod_virtuemart_product/tmpl/quicksearch.php 中找不到类 'mod_virtuemart_product'”

你能告诉我,有什么问题吗?

谢谢你。


这是 mod_virtuemart_product.php 文件。我想将此函数“mod_virtuemart_product::addtocart ($product)”添加到我的文件 quicksearch.php 中,该文件位于 modules/mod_virtuemart_product/tmpl 文件夹中。谢谢。

<?php
defined('_JEXEC') or die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/*
* featured/Latest/Topten/Random Products Module
*
* @version $Id: mod_virtuemart_product.php 2789 2011-02-28 12:41:01Z oscar $
* @package VirtueMart
* @subpackage modules
*
*   @copyright (C) 2010 - Patrick Kohl
*
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* VirtueMart is Free Software.
* VirtueMart comes with absolute no warranty.
*
* www.virtuemart.net
*/


if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'config.php');

VmConfig::loadConfig();
VmConfig::loadJLang('mod_virtuemart_product', true);

// Setting
$max_items =        $params->get( 'max_items', 2 ); //maximum number of items to display
$layout = $params->get('layout','default');
$category_id =      $params->get( 'virtuemart_category_id', null ); // Display products from this category only
$filter_category =  (bool)$params->get( 'filter_category', 0 ); // Filter the category
$display_style =    $params->get( 'display_style', "div" ); // Display Style
$products_per_row = $params->get( 'products_per_row', 4 ); // Display X products per Row
$show_price =       (bool)$params->get( 'show_price', 1 ); // Display the Product Price?
$show_addtocart =   (bool)$params->get( 'show_addtocart', 1 ); // Display the "Add-to-Cart" Link?
$headerText =       $params->get( 'headerText', '' ); // Display a Header Text
$footerText =       $params->get( 'footerText', ''); // Display a footerText
$Product_group =    $params->get( 'product_group', 'featured'); // Display a footerText

$mainframe = Jfactory::getApplication();
$virtuemart_currency_id = $mainframe->getUserStateFromRequest( "virtuemart_currency_id", 'virtuemart_currency_id',JRequest::getInt('virtuemart_currency_id',0) );


$key = 'products'.$category_id.'.'.$max_items.'.'.$filter_category.'.'.$display_style.'.'.$products_per_row.'.'.$show_price.'.'.$show_addtocart.'.'.$Product_group.'.'.$virtuemart_currency_id;

$cache  = JFactory::getCache('mod_virtuemart_product', 'output');
if (!($output = $cache->get($key))) {
    ob_start();
    // Try to load the data from cache.


    /* Load  VM fonction */
    if (!class_exists( 'mod_virtuemart_product' )) require('helper.php');

    $vendorId = JRequest::getInt('vendorid', 1);

    if ($filter_category ) $filter_category = TRUE;

    $productModel = VmModel::getModel('Product');

    $products = $productModel->getProductListing($Product_group, $max_items, $show_price, true, false,$filter_category, $category_id);
    $productModel->addImages($products);

    $totalProd =        count( $products);
    if(empty($products)) return false;
    $currency = CurrencyDisplay::getInstance( );

    if ($show_addtocart) {
        vmJsApi::jPrice();
        vmJsApi::cssSite();
    }
    /* Load tmpl default */
require(JModuleHelper::getLayoutPath('mod_virtuemart_product',$layout));
    $output = ob_get_clean();
    $cache->store($output, $key);
}
echo $output;
?>
4

1 回答 1

0

尝试使用 Joomla 1.6+ 清单标准,因此不应使用<params>,它的结构应如下所示:

<config>
    <fields name="params">
        <fieldset name="basic" addfieldpath="/administrator/components/com_virtuemart/elements">

            <field name="layout" type="filelist" label="MOD_VIRTUEMART_PRODUCT_LAYOUT"
            description="MOD_VIRTUEMART_PRODUCT_LAYOUT_DESC"
            directory="/modules/mod_virtuemart_product/tmpl"
            default="default" hide_default="1" hide_none="1"
            stripext="1" filter="\.php$" exclude="^_" />

            //more fields go here

        </fieldset>
    </fields>
</config>

尝试像这样包含 helper.php 文件,因为它可能无法正确包含:

require_once( dirname(__FILE__).'/helper.php' ); 

更新:

哇!quicksearch.php完全错误的!

  1. 您正在尝试手动包含configuration.php,这是错误的,也可能构成安全威胁。
  2. 您正在使用mysql_*从数据库中获取数据,它不仅使用 Joomla 2.5 编码标准,而且已被弃用并构成安全威胁。
  3. $_POST再次使用when,这不是使用Joomla 2.5 编码标准。

我希望您不打算将此模块放在 Joomla 扩展目录中,因为您正在使您和其他人的网站被黑客入侵。

请大量阅读Joomla 文档

于 2013-08-27T17:01:49.923 回答