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:
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.
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.