Это сделал, добавил || !$this->registerHook('novinki')
<?php
/*
* 2007-2014 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-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_'))
exit;
class NewproductsSlider extends Module
{
protected static $cache_products;
public function __construct()
{
$this->name = 'newproductsslider';
$this->tab = 'front_office_features';
$this->version = '1.6.2';
$this->author = 'Tooniu';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Slider of new products on the homepage');
$this->description = $this->l('Displays new products in slider on homepage.');
}
public function install()
{
$this->_clearCache('*');
Configuration::updateValue('NEWPRODUCTS_NBR', 6);
if (!parent::install()
|| !$this->registerHook('header')
|| !$this->registerHook('addproduct')
|| !$this->registerHook('updateproduct')
|| !$this->registerHook('deleteproduct')
|| !$this->registerHook('categoryUpdate')
|| !$this->registerHook('displayHome')
|| !$this->registerHook('novinki')
)
return false;
return true;
}
public function uninstall()
{
$this->_clearCache('*');
return parent::uninstall();
}
public function getContent()
{
$output = '';
$errors = array();
if (Tools::isSubmit('submitNewproductsSlider'))
{
$nbr = Tools::getValue('NEWPRODUCTS_NBR');
if (!Validate::isInt($nbr) || $nbr <= 0)
$errors[] = $this->l('The number of products is invalid. Please enter a positive number.');
if (isset($errors) && count($errors))
$output = $this->displayError(implode('<br />', $errors));
else
{
Configuration::updateValue('NEWPRODUCTS_NBR', (int)$nbr);
Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('newproducts.tpl'));
$output = $this->displayConfirmation($this->l('Your settings have been updated.'));
}
}
return $output.$this->renderForm();
}
public function hookDisplayHeader($params)
{
$this->hookHeader($params);
}
public function hookHeader($params)
{
if (isset($this->context->controller->php_self) && $this->context->controller->php_self == 'index')
$this->context->controller->addJS($this->_path.'js/newproducts.js');
$this->context->controller->addJS($this->_path.'js/owl.carousel.min.js');
$this->context->controller->addCSS($this->_path.'css/owl.carousel.css');
$this->context->controller->addCSS($this->_path.'css/owl.theme.css');
$this->context->controller->addCSS(_THEME_CSS_DIR_.'product_list.css');
$this->context->controller->addCSS(($this->_path).'newproducts.css', 'all');
}
public function _cacheProducts()
{
if (!isset(NewproductsSlider::$cache_products))
{
$nb = (int)Configuration::get('NEWPRODUCTS_NBR');
NewproductsSlider::$cache_products = Product::getNewProducts((int) $this->context->language->id, 0, (int)$nb);
}
if (NewproductsSlider::$cache_products === false || empty(NewproductsSlider::$cache_products))
return false;
}
public function hookDisplayHome($params)
{
if (!$this->isCached('newproducts.tpl', $this->getCacheId()))
{
$this->_cacheProducts();
$this->smarty->assign(
array(
'products' => NewproductsSlider::$cache_products,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
'items' => Configuration::get('tooniu_nbrhome')
)
);
}
return $this->display(__FILE__, 'newproducts.tpl', $this->getCacheId());
}
public function hookAddProduct($params)
{
$this->_clearCache('*');
}
public function hookUpdateProduct($params)
{
$this->_clearCache('*');
}
public function hookDeleteProduct($params)
{
$this->_clearCache('*');
}
public function hookCategoryUpdate($params)
{
$this->_clearCache('*');
}
public function _clearCache($template, $cache_id = NULL, $compile_id = NULL)
{
parent::_clearCache('NewproductsSlider.tpl');
parent::_clearCache('tab.tpl', 'NewproductsSlider-tab');
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'description' => $this->l('To add products to your homepage, simply add them to the corresponding product category (default: "Home").'),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Number of products to be displayed'),
'name' => 'NEWPRODUCTS_NBR',
'class' => 'fixed-width-xs',
'desc' => $this->l('Set the number of products that you would like to display on homepage (default: 8).'),
),
),
'submit' => array(
'title' => $this->l('Save'),
)
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$this->fields_form = array();
$helper->id = (int)Tools::getValue('id_carrier');
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitNewproductsSlider';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
return $helper->generateForm(array($fields_form));
}
public function getConfigFieldsValues()
{
return array(
'NEWPRODUCTS_NBR' => Tools::getValue('NEWPRODUCTS_NBR', (int)Configuration::get('NEWPRODUCTS_NBR')),
);
}
}
В category.tpl в самом конце добавил {hook h='novinki'}
{*
* 2007-2015 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-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{include file="$tpl_dir./breadcrumb.tpl"}
{include file="$tpl_dir./errors.tpl"}
{if isset($category)}
{if $category->id AND $category->active}
{if $scenes || $category->id_image}
<div class="content_scene_cat">
{if $scenes}
<div class="content_scene">
<!-- Scenes -->
{include file="$tpl_dir./scenes.tpl" scenes=$scenes}
{if $category->description}
<div class="cat_desc rte">
{if Tools::strlen($category->description) > 350}
<div id="category_description_short">{$description_short}</div>
<div id="category_description_full" class="unvisible">{$category->description}</div>
<a href="{$link->getCategoryLink($category->id_category, $category->link_rewrite)|escape:'html':'UTF-8'}" class="lnk_more">{l s='More'}</a>
{else}
<div>{$category->description}</div>
{/if}
</div>
{/if}
</div>
{else}
<!-- Category image -->
<div class="content_scene_cat_bg"{if $category->id_image} style="background:url({$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category_default')|escape:'html':'UTF-8'}) center no-repeat; background-size:cover; min-height:{$categorySize.height}px;"{/if}>
{if $category->description}
<div class="cat_desc">
<span class="category-name">
{strip}
{$category->name|escape:'html':'UTF-8'}
{if isset($categoryNameComplement)}
{$categoryNameComplement|escape:'html':'UTF-8'}
{/if}
{/strip}
</span>
{if Tools::strlen($category->description) > 350}
<div id="category_description_short" class="rte">{$description_short}</div>
<div id="category_description_full" class="unvisible rte">{$category->description}</div>
<a href="{$link->getCategoryLink($category->id_category, $category->link_rewrite)|escape:'html':'UTF-8'}" class="lnk_more">{l s='More'}</a>
{else}
<div class="rte">{$category->description}</div>
{/if}
</div>
{/if}
</div>
{/if}
</div>
{else}
<div class="bighead">
<h1 class="page-heading product-listing"> {strip}
{$category->name|escape:'html':'UTF-8'}
{if isset($categoryNameComplement)}
{$categoryNameComplement|escape:'html':'UTF-8'}
{/if}
{/strip}</h1>
{$category->description}
</div>
<script type="text/javascript">
$(document).ready(function() {
$('.bighead').appendTo( $('#categoryimg') );
});
</script>
{/if}
{if isset($subcategories)}
{if (isset($display_subcategories) && $display_subcategories eq 1) || !isset($display_subcategories) }
<!-- Subcategories -->
<div id="subcategories">
<p class="subcategory-heading">{l s='Subcategories'}</p>
<ul class="clearfix">
{foreach from=$subcategories item=subcategory}
<li>
<a class="subcategory-name" href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}">{$subcategory.name|truncate:25:'...'|escape:'html':'UTF-8'|truncate:350}</a>
</li>
{/foreach}
</ul>
</div>
{/if}
{/if}
{if $products}
<div class="content_sortPagiBar clearfix">
{include file="./product-compare.tpl"}
{include file="./nbr-product-page.tpl"}
{include file="./product-sort.tpl"}
</div>
{include file="./product-list.tpl" products=$products}
<div class="content_sortPagiBar bot">
{include file="./product-compare.tpl"}
{include file="./product-sort.tpl"}
</div>
<div class="bottom-pagination-content clearfix">
{include file="./pagination.tpl" paginationId='bottom'}
</div>
{/if}
{elseif $category->id}
<p class="alert alert-warning">{l s='This category is currently unavailable.'}</p>
{/if}
{/if}
<script type="text/javascript">
$(document).ready(function() {
$('.content_scene_cat').appendTo( $('#categoryimg') );
});
</script>
{hook h='novinki'}
Почистил кэш, зашел в модули - ничего не изменилось. Я так понял, нужно еще функцию создавать, что-то типа этого
public function hooknovinki($params)
{
return $this->display(__FILE__, 'mymodule.tpl');
}
Только что писать вместо __FILE__? И вместо mymodule.tpl должен быть category.tpl?