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 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接