首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Prestashop FrontEnd模块中没有页眉和页脚

Prestashop FrontEnd模块中没有页眉和页脚
EN

Stack Overflow用户
提问于 2017-06-01 20:35:50
回答 0查看 1.4K关注 0票数 1

在Prestashop中无法获取为FrontOffice创建的自定义模块中的页眉和页脚

也不能以$this->context-> theme.css ->addCSS(‘path’)的方式添加路径文件;

主模块文件testmodule.php

代码语言:javascript
复制
<?php

if (!defined('_PS_VERSION_'))
   exit;


/* @var boolean error */
protected $_errors = false;

public function __construct()
{
    $this->name = 'testmodule';
    $this->tab = 'front_office_features';
    $this->version = '1.0';
    $this->author = 'Nemo';
    $this->need_instance = 0;

    parent::__construct();

    $this->displayName = $this->l('testmodule');
    $this->description = $this->l('Adds a block.');
    $this->confirmUninstall = $this->l('Are you sure you want to delete this module?');
    //$this->context->controller->addCSS($this->_path.'testmodule/css/testmodule.css', 'all');
}

public function hookDisplayHeader()
{
  $this->context->controller->addCSS('\themes\PRS01\assets\css\theme.css','all');       
  $this->context->controller->addCSS($this->_path.'css/testmodule.css', 'all');
}


public function initContent(){
        parent::initContent();
        $this->addCSS('\themes\PRS01\assets\css\theme.css');
        $this->setTemplate('allproducts.tpl');  
}   

public function install()
{
    if (!parent::install() &&
!$this->registerHook('header'))
        return false;
    return true;
}

public function uninstall()
{
    if (!parent::uninstall())
        return false;
    return true;
}

public function countAllProducts()
{
    return Db::getInstance()->getValue('SELECT COUNT(*) from ps_product WHERE active = 1');
}
}

控制器文件:

代码语言:javascript
复制
<?php

Class testmoduleAllproductsModuleFrontController extends ModuleFrontController
{


    public function init(){

        $this->page_name = 'allproducts';
        //$this->display_column_left = false;
        parent::init();

    }



    public function setMedia()
    {
        parent::setMedia();

        $this->context->controller->addCSS('\themes\PRS01\assets\css\theme.css', 'all');

    } 

    public function initContent(){
     //   parent::initContent();
     //  echo "hello";

    // $this->setTemplate('allproducts.tpl');   


            //$this->context->controller->addCSS('/js/jquery/ui/jquery-ui.css');
             parent::initContent();

            $products_partial = Product::getProducts($this->context->language->id, 0, 5, 'name', 'asc');
            $products = Product::getProductsProperties($this->context->language->id, $products_partial);

            $this->context->smarty->assign(array(
                'products' => $products,
                'homeSize' => Image::getSize('home_default'),
                'HOOK_HEADER' => Hook::exec('displayHeader')
            ));
            //$this->setTemplate('allproducts.tpl');
          //  setMedia();


            $this->context->controller->addCSS('\themes\PRS01\assets\css\theme.css');
            //$this->addCSS('themes\PRS01\assets\css\theme.css');
             $this->setTemplate('module:testmodule/views/templates/front/allproducts.tpl');
            $this->addCSS('module:testmodule/css/testmodule.css');
            //return $this->display(__FILE__,'views/templates/front/allproducts.tpl');


    } 

}

显示模块的.tpl文件

代码语言:javascript
复制
 <h1> Hello World </h1>
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44307719

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档