我目前正在开发prestashop模块,遇到了一个问题。我为我的模块创建了一个新的钩子,我在我的模块中添加了一个管理控制器来执行这个钩子,我添加了调用钩子并使用模板的函数。除了模板没有出现,我有一个空页面。以下是我所做的代码:
我的模块:
<?php
if (!defined('_PS_VERSION_'))
exit;
/* Checking compatibility with older PrestaShop and fixing it */
if (!defined('_MYSQL_ENGINE_'))
define('_MYSQL_ENGINE_', 'MyISAM');
require_once(_PS_MODULE_DIR_.'blockobjectif/classes/Objectif.php');
class blockobjectif extends Module
{
public function __construct()
{
$this->name = 'blockobjectif';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'Athor Athor';
$this->bootstrap = true;
$this->need_instance = 0;
$this->ps_versions_compliancy['min'] = '1.5';
$this->ps_versions_compliancy['max'] = '1.6';
parent::__construct();
$this->displayName = $this->l('Objectifs');
$this->description = $this->l('Définie des objectifs aux clients');
}
public function install()
{
$sql = array();
include(dirname(__FILE__).'/sql/install.php');
foreach ($sql as $s)
if (!Db::getInstance()->execute($s))
return false;
$class = 'AdminObjectif';
$tab = new Tab();
$tab->class_name = $class;
$tab->module = $this->name;
$tab->id_parent = (int) Tab::getIdFromClassName('AdminParentCustomer');
$langs = Language::getLanguages(false);
foreach ($langs as $l) {
$tab->name[$l['id_lang']] = $this->l('Objectifs');
}
$tab->save();
return parent::install()
&& $this->registerHook('displayCustomerAccount')
&& $this->registerHook('displayAdminObjectifs');
}
public function uninstall($delete_params = true)
{
$sql = array();
include(dirname(__FILE__).'/sql/uninstall.php');
foreach ($sql as $s)
if (!Db::getInstance()->execute($s))
return false;
$moduleTabs = Tab::getCollectionFromModule($this->name);
if (!empty($moduleTabs)) {
foreach ($moduleTabs as $moduleTab) {
$moduleTab->delete();
}
}
if (!parent::uninstall())
return false;
return true;
}
public function hookDisplayCustomerAccount($params)
{
ddd($params);
}
public function hookDisplayAdminObjectifs($params)
{
return $this->display(__FILE__, 'admin-obj.tpl');
}
}
我的AdminObjectiveController:
<?php
class AdminObjectifController extends ModuleAdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->table = 'objectifs';
$this->className = 'Objectif';
parent::__construct();
Hook::exec('displayAdminProductsExtra');
}
}
我看不出问题出在哪里。。。
谢谢你的帮助
这不是显示backoffice控制器模板的正确方法。
以下是你应该尝试的:
<?php
class AdminObjectifController extends ModuleAdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->table = 'objectifs';
$this->className = 'Objectif';
parent::__construct();
}
public function initContent()
{
$tpl = $this->context->smarty->createTemplate($this->getTemplatePath() . 'admin-obj.tpl', $this->context->smarty);
$tpl->assign(array(
'my_var' => "test"
));
$this->content .= $tpl->fetch();
parent::initContent();
}
}
请注意,您的admin-obj.tpl
文件应该放在模块内部的view/tem板/admin/admin-obj.tpl
下。
我需要知道如何在Prestashop上创建一个模块,在管理员上使用自定义视图。留档很差,我不明白如何调用带有控制器传递的参数的视图。我使用的是Prestashop版本1.6。 我已经做了以下步骤: 创建了XML 当我转到管理面板上的选项卡时,我看到一个带有数据库数据的表。我需要加载一个自定义tpl文件,在那里我可以完全自定义我的页面。 我读了这么多的指南和留档(非官方或非官方),但没有明确的。
当我想使用一些自定义URL时,我很难理解应用于自定义模块的逻辑中的错误 所以,我在我的自定义模块“页面”中使用了像这样的钩子ModuleRoutes: 和应该工作的模块控制器: 网址已正确创建,但当我试图访问该页面的内容时,我将最终出现在404错误页面我做错了什么吗?我想我错过了一些很明显的东西,但不明白是什么... 我已经做了研究,但仍然无法找到解决问题的方法。。似乎$route['contro
嗨,我是prestashop的新手,我尝试创建一个1.7版的管理模块。我会创建一个新的菜单来显示模板和管理我的数据库。 mymodule.php: 模块/mymodule/controller/admin/MyModuleController。php: 模块/mymodule/views/templates/admin/mymodule。第三方物流: 我用很多教程1.7/1.6的编译创建了这个,但
我在Prestashop上有一个模块,适用于版本1.6和1.7。 在版本1.6中,我设法在bacok办公室的产品表上显示了一个额外的字段。我希望对1.7版也这样做,但目前还没有成功。。。 我尝试使用DisplayAdminProductsManstepLeftColumn中间钩子 我的模块控制器: 钩子的录音 我的看法是: 你知道怎么了吗?
我正在尝试prestashop 1.7,但在创建自定义模块时遇到了一个问题。我在“modules”文件夹中创建了一个文件夹“mymodule”,正如文档中所示,我创建了一个简单的mymodule。其中的php文件: 然后我进入“模块”下的管理页面- 我犯了什么错误? 谢谢 泽维尔
我在prestashop中创建了一个自定义模块,但我不知道如何处理对该模块的访问。我没有找到任何关于它的文档。我知道怎么在symfony做,但在prestashop不行。我只想让一组用户访问我的模块。有人知道怎么做吗,或者有一个文档链接来帮助我?
有人能帮我解决我遇到的自定义Prestashop模块1.6版本的文件路径问题吗? 以下内容在本地主机环境中非常有效: 但是不能在实时服务器上工作。以下方法确实有效: 这是不可接受的,因为有些客户不会使用默认的引导主题。 对此问题的任何帮助都将不胜感激。 谢谢