【发布时间】:2014-06-12 13:37:04
【问题描述】:
我正在尝试向我的商店添加一些功能,并且在过去的两天里试图了解 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;
}
}
?>
还有
/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');
}
}
?>
这可行,但是我被卡住的地方与 content.tpl 部分有关。为了让它在管理部分的内容区域内创建一个空白页的内容,在 content.tpl 文件中包含什么内容?
我浏览了手册并在论坛上花费了无数小时寻找问题,试图通过分解其他模块来解决问题,但我发现它太复杂了,无法真正理解什么是什么。
如果有人可以帮助我理解这一点,或者向我指出有关此特定主题的信息来源,我们将不胜感激,谢谢!
【问题讨论】:
标签: module admin prestashop