Тема:
http://cms.template-help.com/prestashop_30254/
Поставили модуль:
Slide new products v0.1
slidenewproducts.css
<div id="new-products_block_right" class="block products_block">
<h4><a href="{$base_dir}new-products.php" title="{l s='New products' mod='blocknewproducts'}">Новые товары</a></h4>
<div id="slider">
<div id="mover">
{if $new_products}
{counter start=0 assign=nbPrd}
{foreach from=$new_products item=product name=myLoop}
{if $nbPrd == 0}
<div id="slide-1" class="slide">
{else}
<div class="slide">
{/if}
<a href="{$product.link}" title="{$product.legend|escape:htmlall:'UTF-8'}" class="product_image"><img src="{$img_prod_dir}{$product.id_image}-home.jpg" alt="{$product.legend|escape:htmlall:'UTF-8'}" /></a>
</div>
{counter print=false}
{/foreach}
{else}
<p>{l s='No new product at this time' mod='slidenewproducts'}</p>
{/if}
</div>
</div>
<p><a href="{$base_dir}new-products.php" title="{l s='All new products' mod='blocknewproducts'}" class="button_large">Все новинки</a></p>
</div>
<!-- /MODULE Home Featured Products -->
slidenewproducts.tpl
<div id="new-products_block_right" class="block products_block">
<h4><a href="{$base_dir}new-products.php" title="{l s='New products' mod='blocknewproducts'}">Новые товары</a></h4>
<div id="slider">
<div id="mover">
{if $new_products}
{counter start=0 assign=nbPrd}
{foreach from=$new_products item=product name=myLoop}
{if $nbPrd == 0}
<div id="slide-1" class="slide">
{else}
<div class="slide">
{/if}
<a href="{$product.link}" title="{$product.legend|escape:htmlall:'UTF-8'}" class="product_image"><img src="{$img_prod_dir}{$product.id_image}-home.jpg" alt="{$product.legend|escape:htmlall:'UTF-8'}" /></a>
</div>
{counter print=false}
{/foreach}
{else}
<p>{l s='No new product at this time' mod='slidenewproducts'}</p>
{/if}
</div>
</div>
<p><a href="{$base_dir}new-products.php" title="{l s='All new products' mod='blocknewproducts'}" class="button_large">Все новинки</a></p>
</div>
<!-- /MODULE Home Featured Products -->
slidenewproducts.php
<?php
class SlideNewProducts extends Module
{
private $_html = '';
private $_directory;
private $_filename;
private $_filename_http;
private $_postErrors = array();
function __construct()
{
$this->name = 'slidenewproducts';
$this->tab = 'Tools';
$this->version = 0.1;
parent::__construct(); // The parent construct is required for translations
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Slide new products');
$this->description = $this->l('Shows a slideshow of new products in your home page');
}
function install()
{
if (!Configuration::updateValue('NEW_PRODUCTS_NBR', 50) OR !parent::install() OR !$this->registerHook('rightColumn') OR !$this->registerHook('header'))
return false;
return true;
}
public function getContent()
{
$output = '<h2>'.$this->displayName.'</h2>';
if (Tools::isSubmit('submitslidenewproducts'))
{
$nbr = intval(Tools::getValue('nbr'));
if (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr))
$errors[] = $this->l('Invalid number of product');
else
Configuration::updateValue('NEW_PRODUCTS_NBR', $nbr);
if (isset($errors) AND count($errors))
$output .= $this->displayError(implode('<br />', $errors));
else
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
return $output.$this->displayForm();
}
public function displayForm()
{
$output = '
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
<label>'.$this->l('Number of products to display').'</label>
<div class="margin-form">
<input type="text" size="5" name="nbr" value="'.Tools::getValue('nbr', Configuration::get('NEW_PRODUCTS_NBR')).'" />
<p class="clear">'.$this->l('The number of products displayed on homepage (default: 10)').'</p>
</div>
<center><input type="submit" name="submitslidenewproducts" value="'.$this->l('Save').'" class="button" /></center>
</fieldset>
</form>';
return $output;
}
function hookRightColumn($params)
{
global $smarty;
$currency = new Currency(intval($params['cookie']->id_currency));
$newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, Configuration::get('NEW_PRODUCTS_NBR'));
$new_products = array();
if ($newProducts)
foreach ($newProducts AS $newProduct)
$new_products[] = $newProduct;
$smarty->assign('new_products', $new_products);
return $this->display(__FILE__, 'slidenewproducts.tpl');
}
function hookHeader($params)
{
global $smarty;
ob_start();
?>
<link rel="stylesheet" href="<?php echo $this->_path;?>css/slidenewproducts.css" type="text/css" media="screen" charset="utf-8" />
<script src="<?php echo $this->_path;?>js/startstop-slider.js" type="text/javascript"></script>
<?php
$output = ob_get_contents();
ob_end_clean();
return $output;
}
}