[*] FO : added smarty cache on homefeatured module
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<module>
|
<module>
|
||||||
<name>homefeatured</name>
|
<name>homefeatured</name>
|
||||||
<displayName><![CDATA[Featured products on the homepage.]]></displayName>
|
<displayName><![CDATA[Produits phares sur la page d'accueil]]></displayName>
|
||||||
<version><![CDATA[0.9]]></version>
|
<version><![CDATA[1.0]]></version>
|
||||||
<description><![CDATA[Displays featured products in the middle of your homepage.]]></description>
|
<description><![CDATA[Affiche les produits phares au centre de votre page d'accueil]]></description>
|
||||||
<author><![CDATA[PrestaShop]]></author>
|
<author><![CDATA[PrestaShop]]></author>
|
||||||
<tab><![CDATA[front_office_features]]></tab>
|
<tab><![CDATA[front_office_features]]></tab>
|
||||||
<is_configurable>1</is_configurable>
|
<is_configurable>1</is_configurable>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class HomeFeatured extends Module
|
|||||||
{
|
{
|
||||||
$this->name = 'homefeatured';
|
$this->name = 'homefeatured';
|
||||||
$this->tab = 'front_office_features';
|
$this->tab = 'front_office_features';
|
||||||
$this->version = '0.9';
|
$this->version = '1.0';
|
||||||
$this->author = 'PrestaShop';
|
$this->author = 'PrestaShop';
|
||||||
$this->need_instance = 0;
|
$this->need_instance = 0;
|
||||||
|
|
||||||
@@ -48,17 +48,31 @@ class HomeFeatured extends Module
|
|||||||
|
|
||||||
function install()
|
function install()
|
||||||
{
|
{
|
||||||
if (!Configuration::updateValue('HOME_FEATURED_NBR', 8) || !parent::install() || !$this->registerHook('displayHome') || !$this->registerHook('header'))
|
$this->_clearCache('homefeatured.tpl');
|
||||||
|
if (!Configuration::updateValue('HOME_FEATURED_NBR', 8)
|
||||||
|
|| !parent::install()
|
||||||
|
|| !$this->registerHook('displayHome')
|
||||||
|
|| !$this->registerHook('header')
|
||||||
|
|| !$this->registerHook('addproduct')
|
||||||
|
|| !$this->registerHook('updateproduct')
|
||||||
|
|| !$this->registerHook('deleteproduct')
|
||||||
|
)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function uninstall()
|
||||||
|
{
|
||||||
|
$this->_clearCache('homefeatured.tpl');
|
||||||
|
return parent::uninstall();
|
||||||
|
}
|
||||||
|
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
$output = '<h2>'.$this->displayName.'</h2>';
|
$output = '<h2>'.$this->displayName.'</h2>';
|
||||||
if (Tools::isSubmit('submitHomeFeatured'))
|
if (Tools::isSubmit('submitHomeFeatured'))
|
||||||
{
|
{
|
||||||
$nbr = (int)(Tools::getValue('nbr'));
|
$nbr = (int)Tools::getValue('nbr');
|
||||||
if (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr))
|
if (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr))
|
||||||
$errors[] = $this->l('An invalid number of products has been specified.');
|
$errors[] = $this->l('An invalid number of products has been specified.');
|
||||||
else
|
else
|
||||||
@@ -101,16 +115,34 @@ class HomeFeatured extends Module
|
|||||||
|
|
||||||
public function hookDisplayHome($params)
|
public function hookDisplayHome($params)
|
||||||
{
|
{
|
||||||
$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
|
if (!$this->isCached('homefeatured.tpl', $this->getCacheId('homefeatured')))
|
||||||
$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));
|
{
|
||||||
$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
|
p('no cache');
|
||||||
|
$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
|
||||||
|
$nb = (int)Configuration::get('HOME_FEATURED_NBR');
|
||||||
|
$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
|
||||||
|
|
||||||
$this->smarty->assign(array(
|
$this->smarty->assign(array(
|
||||||
'products' => $products,
|
'products' => $products,
|
||||||
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
||||||
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
|
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId('homefeatured'));
|
||||||
|
}
|
||||||
|
|
||||||
return $this->display(__FILE__, 'homefeatured.tpl');
|
public function hookAddProduct($params)
|
||||||
|
{
|
||||||
|
$this->_clearCache('homefeatured.tpl');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookUpdateProduct($params)
|
||||||
|
{
|
||||||
|
$this->_clearCache('homefeatured.tpl');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookDeleteProduct($params)
|
||||||
|
{
|
||||||
|
$this->_clearCache('homefeatured.tpl');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('_PS_VERSION_'))
|
||||||
|
exit;
|
||||||
|
|
||||||
|
function upgrade_module_1_0($object)
|
||||||
|
{
|
||||||
|
return ($object->registerHook('addproduct') && $object->registerHook('updateproduct') && $object->registerHook('deleteproduct'));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user