dongtuji0992 2015-10-02 06:16
浏览 52
已采纳

PrestaShop 1.6:在CMS页面上显示模块内容(中心列)

I am new to PrestaShop working on 1.6.0.9 version. I have developed one module to manage news. It have 5 fields- news title, news details, news image, news status and news publish date. The module works perfectly at back office. Now I want to show all the news created in this module on the front side. Please see the image below:

Header Menu

This is my header menu. It is having last option as Press which is currently a CMS page. Now I want the contents of my news module to be shown on this page, rather than the contents added from CMS block module.

First of all, is it possible? If yes, is there any way to do this or any suggestions or modifications?

If no, is there any alternate way to show the module contents on front office on a separate page on menu option click?

Thank you for your time to read the question. Any help is appreciated.

  • 写回答

1条回答 默认 最新

  • doumao1047 2015-10-03 10:33
    关注

    Why can't you, try to display it in a separate page instead of cms page and add a url link in blocktopmenu.

    You can create a front page easily in few steps

    Step - 1: Create a front controller

    let your module name is Blockexample

    your directory structure is module/module_name/controllers/front/controller_name.php

    i.e., "module/blockexample/controllers/front/test.php"

    class name convention must follow as below:

    class modulename+controllername+ModuleFrontController extends ModuleFrontController()

    eg: Blockexample+Test+ModuleFrontController

    Create a test controller in the above path and add below code.

    class BlockexampleTestModuleFrontController extends ModuleFrontController
    {
    
    public function init()
    {
        $this->page_name = 'testpage'; // page_name and body id
        $this->display_column_left = false; // hides left column
        parent::init();
    }
    
    public function initContent()
    {
         parent::initContent();
         //path for displaying in breadcrumb, use this array to pass values to view file
         $this->context->smarty->assign(array('path'=>'Test')); 
         $this->setTemplate('test.tpl');
    }
    
    //for linking your css and javascript    
    public function setMedia() 
    {
        parent::setMedia();
        $this->addCSS(__PS_BASE_URI__.'modules/'.$this->module->name.'/css/'.$this->module->name.'.css');
        $this->addJS(__PS_BASE_URI__.'modules/'.$this->module->name.'/js/'.$this->module->name.'.js');    
    }
    
    }
    

    Step - 1 : Create a view

    Your view directory structure is

    module/module_name/views/templates/front/file_name.tpl

    i.e, "module/blockexample/views/templates/front/test.tpl"

    Now create a tpl file in above path and add just "hello world".

    Step - 3: Access your module in front end

    Now open the link in browser

    url format: http://domain.com/index.php?fc=module&module=module_name&controller=controller_name

    eg: www.example.com/index.php?fc=module&module=blockexample&controller=test

    Now you can add your link in the above format and create a new link in blocktopmenu in your backoffice.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 链接问题 C++LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接