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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?