goosedesign Posted December 24, 2013 Share Posted December 24, 2013 I made a ridiculously simple little module to display the contents of a pre-defined cms page in a box on the shop home page. The admin can use use that page for promotions and as a general notice board. Unfortunately it no longer works after upgrading to 1.5. Can anybody tell from the code what might need to be changed to make it compatible? Here's the PHP <?php class BlockPink extends Module { function __construct() { $this->name = 'blockpink'; parent::__construct(); $this->tab = 'Blocks'; $this->version = '0.1.0'; $this->displayName = $this->l('Pink Box'); $this->description = $this->l('Adds a pink box to the home page showing text from the "pink box" page in the CMS'); } public function install() { parent::install(); if (!$this->registerHook('home')) return false; } function hookHome($params) { global $smarty; $query = "SELECT * FROM ps_cms_lang WHERE id_cms = '7' AND id_lang = '1'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $cms = $row['content']; $smarty->assign(array( 'cms' => $cms)); $errors = array(); return $this->display(__FILE__, 'blockpink.tpl'); } } And the template: <div id="pink_block"> {if $cms} {$cms} {else} {l s='This page does not exist.'} {/if} </div> Many, many thanks for any light anyone can shed on this. Link to comment Share on other sites More sharing options...
Divyesh Prajapati Posted December 24, 2013 Share Posted December 24, 2013 I made a ridiculously simple little module to display the contents of a pre-defined cms page in a box on the shop home page. The admin can use use that page for promotions and as a general notice board. Unfortunately it no longer works after upgrading to 1.5. Can anybody tell from the code what might need to be changed to make it compatible? Here's the PHP <?php class BlockPink extends Module { function __construct() { $this->name = 'blockpink'; parent::__construct(); $this->tab = 'Blocks'; $this->version = '0.1.0'; $this->displayName = $this->l('Pink Box'); $this->description = $this->l('Adds a pink box to the home page showing text from the "pink box" page in the CMS'); } public function install() { parent::install(); if (!$this->registerHook('home')) return false; } function hookHome($params) { global $smarty; $query = "SELECT * FROM ps_cms_lang WHERE id_cms = '7' AND id_lang = '1'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $cms = $row['content']; $smarty->assign(array( 'cms' => $cms)); $errors = array(); return $this->display(__FILE__, 'blockpink.tpl'); } } And the template: <div id="pink_block"> {if $cms} {$cms} {else} {l s='This page does not exist.'} {/if} </div> Many, many thanks for any light anyone can shed on this. So you only want to use pre-defined page means fixed page to be shown on your home page ??? Link to comment Share on other sites More sharing options...
shailendra Posted December 24, 2013 Share Posted December 24, 2013 hookHome is replaced by hookDisplayHome. http://doc.prestashop.com/display/PS15/Hooks+in+PrestaShop+1.5 so you need to change as below replace $this->registerHook('home') by $this->registerHook('displayhome') and function hookHome($params) by function hookDisplayHome($params) Link to comment Share on other sites More sharing options...
vekia Posted December 24, 2013 Share Posted December 24, 2013 hookHome works the same as hookDisplayHome, there is no differencies. Link to comment Share on other sites More sharing options...
Divyesh Prajapati Posted December 25, 2013 Share Posted December 25, 2013 (edited) Hello All, Here is complete module to show content of any page on your Home page dynamically, For configuration see attached snap shot. Download and install this module en Enjoy! Regards, Divyesh Prapati. blockpink.zip Edited December 25, 2013 by divyeshp (see edit history) 1 Link to comment Share on other sites More sharing options...
goosedesign Posted December 25, 2013 Author Share Posted December 25, 2013 Oh wow Divyesh, thank you so much! That works perfectly. Link to comment Share on other sites More sharing options...
vekia Posted December 25, 2013 Share Posted December 25, 2013 btw module like that exists since may 2013 cms page on homepage FREE Link to comment Share on other sites More sharing options...
Recommended Posts