[+] MO: Add Module->smartyAssign method, in order to assign variables with module name as prefix in module's templates

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8718 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-09-22 12:05:49 +00:00
parent b24d2fa274
commit 2dbea99b61
19 changed files with 174 additions and 155 deletions
+9 -7
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -42,7 +42,7 @@ class HomeFeatured extends Module
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Featured Products on the homepage');
$this->description = $this->l('Displays Featured Products in the middle of your homepage.');
}
@@ -82,7 +82,7 @@ class HomeFeatured extends Module
<div class="margin-form">
<input type="text" size="5" name="nbr" value="'.Tools::getValue('nbr', (int)(Configuration::get('HOME_FEATURED_NBR'))).'" />
<p class="clear">'.$this->l('The number of products displayed on homepage (default: 10).').'</p>
</div>
<center><input type="submit" name="submitHomeFeatured" value="'.$this->l('Save').'" class="button" /></center>
</fieldset>
@@ -95,10 +95,12 @@ class HomeFeatured extends Module
$category = new Category(Context::getContext()->shop->getCategory(), Configuration::get('PS_LANG_DEFAULT'));
$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));
$products = $category->getProducts($params['cookie']->id_lang, 1, ($nb ? $nb : 10));
$this->context->smarty->assign(array(
'products' => $products,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image::getSize('home')));
$this->smartyAssign(array(
'products' => $products,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image::getSize('home'),
));
return $this->display(__FILE__, 'homefeatured.tpl');
}
+6 -6
View File
@@ -1,5 +1,5 @@
{*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -27,23 +27,23 @@
<!-- MODULE Home Featured Products -->
<div id="featured-products_block_center" class="block products_block">
<h4>{l s='Featured products' mod='homefeatured'}</h4>
{if isset($products) AND $products}
{if isset($homefeatured_products) AND $homefeatured_products}
<div class="block_content">
{assign var='liHeight' value=342}
{assign var='nbItemsPerLine' value=4}
{assign var='nbLi' value=$products|@count}
{assign var='nbLi' value=$homefeatured_products|@count}
{math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines}
{math equation="nbLines*liHeight" nbLines=$nbLines|ceil liHeight=$liHeight assign=ulHeight}
<ul style="height:{$ulHeight}px;">
{foreach from=$products item=product name=homeFeaturedProducts}
{foreach from=$homefeatured_products item=product name=homeFeaturedProducts}
<li class="ajax_block_product {if $smarty.foreach.homeFeaturedProducts.first}first_item{elseif $smarty.foreach.homeFeaturedProducts.last}last_item{else}item{/if} {if $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 0}last_item_of_line{elseif $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 1}clear{/if} {if $smarty.foreach.homeFeaturedProducts.iteration > ($smarty.foreach.homeFeaturedProducts.total - ($smarty.foreach.homeFeaturedProducts.total % $nbItemsPerLine))}last_line{/if}">
<h5><a href="{$product.link}" title="{$product.name|truncate:32:'...'|escape:'htmlall':'UTF-8'}">{$product.name|truncate:27:'...'|escape:'htmlall':'UTF-8'}</a></h5>
<div class="product_desc"><a href="{$product.link}" title="{l s='More' mod='homefeatured'}">{$product.description_short|strip_tags|truncate:130:'...'}</a></div>
<a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}" class="product_image"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" /></a>
<a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}" class="product_image"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" height="{$homefeatured_homeSize.height}" width="{$homefeatured_homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" /></a>
<div>
{if $product.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<p class="price_container"><span class="price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span></p>{else}<div style="height:21px;"></div>{/if}
<a class="button" href="{$product.link}" title="{l s='View' mod='homefeatured'}">{l s='View' mod='homefeatured'}</a>
{if ($product.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $product.available_for_order AND !isset($restricted_country_mode) AND $product.minimal_quantity == 1 AND $product.customizable != 2 AND !$PS_CATALOG_MODE}
{if ($product.id_product_attribute == 0 OR (isset($homefeatured_add_prod_display) AND ($homefeatured_add_prod_display == 1))) AND $product.available_for_order AND !isset($restricted_country_mode) AND $product.minimal_quantity == 1 AND $product.customizable != 2 AND !$PS_CATALOG_MODE}
{if ($product.quantity > 0 OR $product.allow_oosp)}
<a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product}" href="{$link->getPageLink('cart', true, NULL, "qty=1&amp;id_product={$product.id_product}&amp;token={$static_token}&amp;add")}" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart' mod='homefeatured'}</a>
{else}