[*] FO : New hooks for home tabs

This commit is contained in:
gRoussac
2013-10-16 11:44:55 +02:00
parent 2e65214c39
commit 62aaf16d60
22 changed files with 156 additions and 229 deletions
+16 -13
View File
@@ -34,9 +34,10 @@ class BlockBestSellers extends Module
public function __construct()
{
$this->name = 'blockbestsellers';
$this->tab = 'front_office_features';
$this->version = '1.2';
$this->version = '1.3';
$this->author = 'PrestaShop';
$this->need_instance = 0;
@@ -52,15 +53,16 @@ class BlockBestSellers extends Module
public function install()
{
$this->_clearCache('blockbestsellers.tpl');
$this->_clearCache('blockbestsellers-home.tpl');
$this->_clearCache('tab.tpl');
if (!parent::install()
|| !$this->registerHook('rightColumn')
|| !$this->registerHook('header')
|| !$this->registerHook('actionOrderStatusPostUpdate')
|| !$this->registerHook('addproduct')
|| !$this->registerHook('updateproduct')
|| !$this->registerHook('deleteproduct')
|| !$this->registerHook('displayHomeTab')
|| !$this->registerHook('displayHomeTabContent')
|| !ProductSale::fillProductSales()
)
return false;
@@ -70,7 +72,7 @@ class BlockBestSellers extends Module
public function uninstall()
{
$this->_clearCache('blockbestsellers.tpl');
$this->_clearCache('blockbestsellers-home.tpl');
$this->_clearCache('tab.tpl');
return parent::uninstall();
}
@@ -78,25 +80,21 @@ class BlockBestSellers extends Module
public function hookAddProduct($params)
{
$this->_clearCache('blockbestsellers.tpl');
$this->_clearCache('blockbestsellers-home.tpl');
}
public function hookUpdateProduct($params)
{
$this->_clearCache('blockbestsellers.tpl');
$this->_clearCache('blockbestsellers-home.tpl');
}
public function hookDeleteProduct($params)
{
$this->_clearCache('blockbestsellers.tpl');
$this->_clearCache('blockbestsellers-home.tpl');
}
public function hookActionOrderStatusPostUpdate($params)
{
$this->_clearCache('blockbestsellers.tpl');
$this->_clearCache('blockbestsellers-home.tpl');
}
/**
@@ -175,9 +173,14 @@ class BlockBestSellers extends Module
$this->context->controller->addCSS($this->_path.'blockbestsellers.css', 'all');
}
public function hookHome($params)
public function hookDisplayHomeTab($params)
{
if (!$this->isCached('blockbestsellers-home.tpl', $this->getCacheId('blockbestsellers-home')))
return $this->display(__FILE__, 'tab.tpl', $this->getCacheId('blockbestsellers-tab'));
}
public function hookdisplayHomeTabContent($params)
{
if (!$this->isCached('blockbestsellers.tpl', $this->getCacheId()))
{
$best_sellers = $this->getBestSellers($params);
if ($best_sellers === false)
@@ -187,12 +190,12 @@ class BlockBestSellers extends Module
'best_sellers' => $best_sellers,
'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
}
return $this->display(__FILE__, 'blockbestsellers-home.tpl', $this->getCacheId('blockbestsellers-home'));
return $this->display(__FILE__, 'blockbestsellers.tpl', $this->getCacheId());
}
public function hookRightColumn($params)
{
if (!$this->isCached('blockbestsellers.tpl', $this->getCacheId('blockbestsellers')))
if (!$this->isCached('blockbestsellers.tpl', $this->getCacheId()))
{
$best_sellers = $this->getBestSellers($params);
if ($best_sellers === false)
@@ -204,7 +207,7 @@ class BlockBestSellers extends Module
'smallSize' => Image::getSize(ImageType::getFormatedName('small'))
));
}
return $this->display(__FILE__, 'blockbestsellers.tpl', $this->getCacheId('blockbestsellers'));
return $this->display(__FILE__, 'blockbestsellers.tpl', $this->getCacheId());
}
public function hookLeftColumn($params)
+25
View File
@@ -0,0 +1,25 @@
{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<li><a class="blockbestsellers">{l s='Best Sellers' mod='blockbestsellers'}</a></li>
@@ -0,0 +1,9 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
function upgrade_module_1_3($object)
{
return ($object->unregisterHook('rightColumn') && $object->registerHook('displayHomeTab') && $object->registerHook('displayHomeTabContent'));
}
+10 -3
View File
@@ -33,7 +33,7 @@ class BlockNewProducts extends Module
{
$this->name = 'blocknewproducts';
$this->tab = 'front_office_features';
$this->version = '1.4';
$this->version = '1.5';
$this->author = 'PrestaShop';
$this->need_instance = 0;
@@ -46,12 +46,13 @@ class BlockNewProducts extends Module
public function install()
{
if (!parent::install()
|| !$this->registerHook('rightColumn')
|| !$this->registerHook('header')
|| !$this->registerHook('addproduct')
|| !$this->registerHook('updateproduct')
|| !$this->registerHook('deleteproduct')
|| !Configuration::updateValue('NEW_PRODUCTS_NBR', 5)
|| !$this->registerHook('displayHomeTab')
|| !$this->registerHook('displayHomeTabContent')
)
return false;
$this->_clearCache('blocknewproducts.tpl');
@@ -61,6 +62,7 @@ class BlockNewProducts extends Module
public function uninstall()
{
$this->_clearCache('blocknewproducts.tpl');
$this->_clearCache('tab.tpl');
return parent::uninstall();
}
@@ -110,8 +112,13 @@ class BlockNewProducts extends Module
{
return $this->hookRightColumn($params);
}
public function hookdisplayHomeTab($params)
{
return $this->display(__FILE__, 'tab.tpl', $this->getCacheId('blocknewproducts-tab'));
}
public function hookHome($params)
public function hookdisplayHomeTabContent($params)
{
return $this->hookRightColumn($params);
}
+25
View File
@@ -0,0 +1,25 @@
{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<li class="active"><a class="blocknewproducts">{l s='New arrivals' mod='blocknewproducts'}</a></li>
@@ -0,0 +1,9 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
function upgrade_module_1_5($object)
{
return ($object->unregisterHook('rightColumn') && $object->registerHook('displayHomeTab') && $object->registerHook('displayHomeTabContent'));
}
+18 -5
View File
@@ -36,7 +36,7 @@ class HomeFeatured extends Module
{
$this->name = 'homefeatured';
$this->tab = 'front_office_features';
$this->version = '1.1';
$this->version = '1.2';
$this->author = 'PrestaShop';
$this->need_instance = 0;
@@ -52,11 +52,12 @@ class HomeFeatured extends Module
Configuration::updateValue('HOME_FEATURED_NBR', 8);
if (!parent::install()
|| !$this->registerHook('displayHome')
|| !$this->registerHook('header')
|| !$this->registerHook('addproduct')
|| !$this->registerHook('updateproduct')
|| !$this->registerHook('deleteproduct')
|| !$this->registerHook('displayHomeTab')
|| !$this->registerHook('displayHomeTabContent')
)
return false;
return true;
@@ -65,6 +66,7 @@ class HomeFeatured extends Module
public function uninstall()
{
$this->_clearCache('homefeatured.tpl');
$this->_clearCache('tab.tpl');
return parent::uninstall();
}
@@ -97,9 +99,14 @@ class HomeFeatured extends Module
$this->context->controller->addJS(($this->_path).'js/homefeatured.js');
}
public function hookDisplayHome($params)
public function hookDisplayHomeTab($params)
{
if (!$this->isCached('homefeatured.tpl', $this->getCacheId('homefeatured')))
return $this->display(__FILE__, 'tab.tpl', $this->getCacheId('homefeatured-tab'));
}
public function hookDisplayHomeTabContent($params)
{
if (!$this->isCached('homefeatured.tpl', $this->getCacheId()))
{
$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
$nb = (int)Configuration::get('HOME_FEATURED_NBR');
@@ -111,7 +118,13 @@ class HomeFeatured extends Module
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
));
}
return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId('homefeatured'));
return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId());
}
/* Retro Compatibility < 1.6.0.1 */
public function hookDisplayHome($params)
{
return $this->hookDisplayHomeTabContent();
}
public function hookAddProduct($params)
+5 -5
View File
@@ -25,12 +25,12 @@
$(document).ready(function()
{
$('.title_block').click(function(){
$('.home_tab li a').click(function(){
var button = $(this);
$('#index #center_column .products_block').removeClass('active');
button.parent('.products_block').addClass('active');
$('#index #center_column .products_block .block_content').hide(0, function(){
button.next('.block_content').show(0);
$('.home_tab li').removeClass('active');
button.parent('li').addClass('active');
$('.home_tab_content .product_list').hide(0, function(){
$('.home_tab_content .' + button.prop('class')).show(0).addClass('active').removeClass('hidden');
});
});
});
+25
View File
@@ -0,0 +1,25 @@
{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<li><a class="homefeatured">{l s='Popular' mod='homefeatured'}</a></li>
@@ -0,0 +1,9 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
function upgrade_module_1_2($object)
{
return ($object->unregisterHook('displayHome') && $object->registerHook('displayHomeTab') && $object->registerHook('displayHomeTabContent'));
}