Jump to content

Dublicate special block


eldonate

Recommended Posts

Sure,

1) copy the whole folder /modules/blockspecials to a folder /modules/blockspecials2

2) copy the whole folder themes/<your theme folder>//modules/blockspecials to a folder themes/<your theme folder>/modules/blockspecials2

 

Then go to  folder  /modules/blockspecialsand edit file names:

 

blockspecials.php ->blockspecials2.php

blockspecials.tpl -> blockspecials2.tpl

blockspecials.css ->blockspecials2.css

 

 

then edit file blockspecials2.php and add a few 2's:

 

 

class BlockSpecials2 extends Module
{
private $_html = '';
private $_postErrors = array();
 
    function __construct()
    {
        $this->name = 'blockspecials2';
        $this->tab = 'pricing_promotion';
        $this->version = '0.8';
$this->author = 'PrestaShop';
$this->need_instance = 0;
 
parent::__construct();
 
$this->displayName = $this->l('Specials block 2');
$this->description = $this->l('Adds a 2nd block displaying current product specials.');
}
 
---
 
public function hookRightColumn($params)
{
if (Configuration::get('PS_CATALOG_MODE'))
return ;
 
if (!($special = Product::getRandomSpecial((int)$params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
return;
 
$this->smarty->assign(array(
'special' => $special,
'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
));
 
return $this->display(__FILE__, 'blockspecials2.tpl');
}
 
public function hookLeftColumn($params)
{
return $this->hookRightColumn($params);
}
 
public function hookHeader($params)
{
if (Configuration::get('PS_CATALOG_MODE'))
return ;
$this->context->controller->addCSS(($this->_path).'blockspecials2.css', 'all');
}
}
 
 
 

and if you want to make it independent of the settings in blockspecials, change all instances of:

PS_BLOCK_SPECIALS_DISPLAY into PS_BLOCK_SPECIALS_DISPLAY2

 

in the same file.

 

 

 

if you want any translation different for both modules, you can change all occurences of 'blockspecials' to 'blockspecials2' in the themes/<your theme folder>/modules/blockspecials2/blockspecials2.tpl file

 

 

I think that's about it.

When finished, go to modules-?modules and install the new module like normal.

 

I hope I didn't forget anything,

pascal.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...