Prestashop 1.7
我正在尝试建立一个新模块,该模块将根据用户首选项自定义布局。逻辑如下:
tableicon
图标的下一个网格图标。tableicon
(在类别页面中),则无需分页即可将用户重定向到其他页面(具有其他视图-假设是表格视图)。因此,这里展示了一个类别的所有产品。tableicon
视图应在开头显示。目标是提出两种不同的布局:
我不想覆盖默认值!
我已经成功创建了'Module Front Controller',它可以显示自定义页面(自定义.tpl文件)。 但是,现在我有以下问题:
1. How to display the list of the product associated with the selected category by the user? (in display.tpl)
2. How to save the current display setting to make sure that next time the expected layout will be presented?
在my_project / modules / hurt / hurt.php中:
<?php
if (!defined('_PS_VERSION_'))
exit;
class Hurt extends Module
{
public function __construct()
{
$this->name = 'hurt';
$this->tab = 'front_office_features';
$this->version = '1.0.1';
$this->author = 'me';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.7', 'max' =>
_PS_VERSION_);
$this->bootstrap = true;
$this->controllers = array('dispaly');
parent::__construct();
$this->displayName = $this->l('Test Front Controllers');
$this->description = $this->l('This module tests');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall the module?');
}
public function install()
{
return parent::install()
}
public function uninstall()
{
return parent::uninstall();
}
}
在my_project / modules / hurt / controllers / front / display.php中:
class HurtDisplayModuleFrontController extends ModuleFrontController
{
public function initContent()
{
$products = "??? What should I pass ???";
$this->context->smarty->assign("products", $products);
$this->setTemplate('module:hurt/views/templates/front/display.tpl');
parent::initContent();
}
}
在my_project / modules / hurt / views / templates / front / display.tpl中:
{extends file='page.tpl'}
{block name='page_content'}
{foreach product=$from item=product name=products}
My table here...
{/foreach}
{/block}