Module Prestashop 1.6-后台-Smarty-创建一个可以生成简单空白页的模块?

Module Prestashop 1.6-后台-Smarty-创建一个可以生成简单空白页的模块?,module,admin,prestashop,Module,Admin,Prestashop,我正在尝试为我的商店添加一些功能,在过去的两天里,我一直在努力了解smarty在prestashop或者更确切地说在一般情况下是如何工作的 到目前为止,我已经制作了一个可以安装的模块,在安装时它会在左侧菜单上创建一个选项卡,我可以单击该选项卡,它将加载控制器,但这就是我卡住的地方。。。我不知道如何在该状态下显示自定义内容 我想要的是非常简单的,只是一段文字和一个按钮。当点击按钮时,我会做一些事情并记录一些事情,然后将结果显示为一个简单的报告 所以首先。。。我想创建带有段落和按钮的页面 因此,我在

我正在尝试为我的商店添加一些功能,在过去的两天里,我一直在努力了解smarty在prestashop或者更确切地说在一般情况下是如何工作的

到目前为止,我已经制作了一个可以安装的模块,在安装时它会在左侧菜单上创建一个选项卡,我可以单击该选项卡,它将加载控制器,但这就是我卡住的地方。。。我不知道如何在该状态下显示自定义内容

我想要的是非常简单的,只是一段文字和一个按钮。当点击按钮时,我会做一些事情并记录一些事情,然后将结果显示为一个简单的报告

所以首先。。。我想创建带有段落和按钮的页面

因此,我在模块目录中创建了一个名为priceupdate的文件夹

其中包括:

/priceupdate.php

<?php
if (!defined('_PS_VERSION_'))
    exit;

class PriceUpdate extends Module
{
    public function __construct()
    {
        $this->name = 'priceupdate';
        $this->tab = 'quick_bulk_update';
        $this->version = '0.8';
        $this->author = 'Me';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('Pricing Update');
        $this->description = $this->l('Adds functionality relating to maintaining product my prices.');  

        $this->confirmUninstall = $this->l('Are you sure you would like to uninstall?');

    }

    public function install()
    {
        if (!parent::install()
            || !$this->installModuleTab('AdminPricingUpdate', array(1=>'Pricing Update'), 0))
            return false;
        return true;
    }

    public function uninstall()
    {
        if (!parent::uninstall()
            || !$this->uninstallModuleTab('AdminPricingUpdate', array(1=>'Pricing  Update'), 0))
            return false;
        return true;
    }

    private function installModuleTab($tabClass, $tabName, $idTabParent)

    {    
        $tab = new Tab();

        $tab->name = $tabName;

        $tab->class_name = $tabClass;

        $tab->module = $this->name;

        $tab->id_parent = $idTabParent;

        if(!$tab->save())

            return false;

        return true;

    }

    private function uninstallModuleTab($tabClass)

    {       
        $idTab = Tab::getIdFromClassName($tabClass);

        if($idTab != 0)

        {

            $tab = new Tab($idTab);

            $tab->delete();

            return true;

        }

        return false;

    }

}
?>
/priceupdate.php

/controllers/admin/AdminPricingUpdateController.php
但是,当我遇到与content.tpl部分相关的问题时,这种方法就起作用了。为了使content.tpl文件在管理部分的内容区域内成为一个空白的内容页面,该文件的内部是什么

我浏览了手册,花了无数时间在论坛上寻找问题,试图通过分解其他模块来解决问题,但我发现它太复杂了,无法真正理解什么是问题

如果有人能帮助我理解这一点,或者给我指出关于这个特定主题的信息来源,那么我们将不胜感激,谢谢

如果您需要“管理部分内容区域内的空白内容页”,则需要将content.tpl设置为空白


请注意,在我的示例中,如果模板名为“content.tpl”,则不必设置模板的名称。

谢谢您的输入,我非常感谢!但是,如果我将content.tpl留空,它只会生成一个没有内容的白色页面。我想将内容添加到后台实际内容区域内的新页面中(就像显示所有仪表板信息的位置一样——所有信息,但只需一个小按钮和一些文字)。我确实查看了你所说的,它看起来像是对prestashop的修改,添加了一个菜单。我基本上了解它是如何工作的,但唯一的问题不是,如果我的控制器中有,它只是加载了一个白色页面太。。。content.tpl位于
modules/priceupdate/
中,这种结构的代码示例将非常有帮助,实际上与1.6中的后端无关:(从上面的链接和content.tpl的位置查看我的示例。它在这里工作得很好,嗯……我试图像您在上一个示例中一样进行设置,但是当我尝试单击新链接时,它会显示
Controller not found
。我检查了class_索引文件,并且
AdminPageController
值指向一个con。)确实存在的troller?有什么想法吗?好吧,我做了答案中的步骤,它成功了。请重试这些步骤,并按照描述的方式执行。您要么没有创建控制器,要么在创建之后没有删除类索引。
/controllers/admin/AdminPricingUpdateController.php

<?php
class AdminPricingUpdateController extends AdminController
{

    public function __construct()

    {

        $this->lang = (!isset($this->context->cookie) || !is_object($this->context->cookie)) ? intval(Configuration::get('PS_LANG_DEFAULT')) : intval($this->context->cookie->id_lang);

        parent::__construct();

    }

    public function display(){

        parent::display();

    }

    public function renderList() {

        return $this->context->smarty->fetch(dirname(__FILE__).'/content.tpl');

    }   
}
?>