Jump to content

Custom module doesn't work in 1.5


Recommended Posts

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

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

×
×
  • Create New...