[Помощь] foreach - $smarty.foreach.item.iteration is div - своя разметка!

KPACHODAP

DELETED
Регистрация
21 Дек 2009
Сообщения
670
Реакции
274
Народ помогите у только второго дива поставить значение style="margin-left:10px; margin-right:0px;"

пытался {if $smarty.foreach.item.iteration is div by 2}style="margin-left:10px; margin-right:0px;"{/if}

она ставит на каждом втором элементе стиль, пробывал index естественно он делает все наоборот!!

помогите плиз!!! если что не понятно говорите!


Есть список товаров:

Код:
<div class="centerBoxWrapper" id="featuredProducts">
<h2 class="centerBoxHeading">Спец предложения</h2>
       
       
{foreach from=$__products item=_product name=item}
{if $_product.slug}
{assign var=_product_url value="?productID=`$_product.productID`&product_slug=`$_product.slug`"|set_query_html}
{else}
{assign var=_product_url value="?productID=`$_product.productID`"|set_query_html}
{/if}





<div class="centerBoxContentsFeatured centeredContent back" style="width:33%;"><div class="product-col"

{if $smarty.foreach.item.iteration is div by 5}style="margin-left:10px; margin-right:0px;"{/if}
{if $smarty.foreach.item.iteration is div by 3}style="margin-left:20px;"{/if}
>
<div class="img">

<a href="{$_product_url}" title="{$_product.name|escape:'html'}"><img id="img_{$_product.productID}" src="{$smarty.const.URL_PRODUCTS_PICTURES}/{$_product.thumbnail|escape:'url'}" title="{$_product.name|escape:'html'}" alt="{$_product.name|escape:'html'}" style="max-width:181px;max-height:181px;" /></a>

</div>
<div class="prod-info">
<a class="name" href="{$_product_url}" >{$_product.name|escape:'html'}</a>
<div class="wrapper">
{if $_product.Price}
<div class="price">
<strong>{$_product.price_str}</strong>
</div>
{/if}
<div class="button"><a href="{$_product_url}" ><img src="/published/SC/html/scripts/repo_themes/vsvkus_v2/all/buttons/english/button_goto_prod_details.png"  alt="{$_product.name|escape:'html'}" title="{$_product.name|escape:'html'}" width="56" height="26"/></a></div>
</div>
</div>
</div></div>


{if $smarty.foreach.item.iteration is div by 3}<br class="clearBoth"/>{/if}

{/foreach}

</div>
 
опиши полностью задачу для чего нужно, пример в картинке не помешал бы
 
опиши полностью задачу для чего нужно, пример в картинке не помешал бы

суть в том чтобы получить полную копию верстки шаблона а она такая!

суть в верстке у класса
<div class="product-col" style="margin-left:10px; margin-right:0px;">

она везде разная практически мне надо понять можно ли конкретно для второго элемента сделать вывод нужного стиля!?!?!?!?!?!


Код:
<div class="column-center-padding">
<div class="centerColumn" id="indexDefault">
<div id="indexDefaultMainContent"></div>
<div class="centerBoxWrapper" id="featuredProducts">
<h2 class="centerBoxHeading">Featured Products</h2>
<div class="centerBoxContentsFeatured centeredContent back" style="width:33%;"><div class="product-col">
<div class="img">
<a href="#1_31&1812up9agstjhkpt4e3n5t23.htm" ><img src="images/01.jpg"  alt="Dolor sit amet consectetur set magna" title=" Dolor sit amet consectetur set magna " width="181" height="135"/></a>
</div>
<div class="prod-info">
<a class="name" href="#1_31&1812up9agstjhkpt4e3n5t23.htm" >Dolor sit amet consectetur set magna</a>
<div class="wrapper">
<div class="price">
<strong>$550.00</strong>
</div>
<div class="button"><a href="#1_31&1812up9agstjhkpt4e3n5t23.htm" ><img src="img/button_goto_prod_details.png"  alt="Go To This Product's Detailed Information" title=" Go To This Product's Detailed Information " width="56" height="26"/></a></div>
</div>
</div>
</div></div>
<div class="centerBoxContentsFeatured centeredContent back" style="width:33%;"><div class="product-col" style="margin-left:10px; margin-right:0px;">
<div class="img">
<a href="#1_31&2812up9agstjhkpt4e3n5t23.htm" ><img src="images/02.jpg"  alt="Lorem set sit amet conse cteturset magna" title=" Lorem set sit amet conse cteturset magna " width="181" height="135"/></a>
</div>
<div class="prod-info">
<a class="name" href="#1_31&2812up9agstjhkpt4e3n5t23.htm" >Lorem set sit amet conse cteturset magna</a>
<div class="wrapper">
<div class="price">
<strong>$160.00</strong>
</div>
<div class="button"><a href="#1_31&2812up9agstjhkpt4e3n5t23.htm" ><img src="img/button_goto_prod_details.png"  alt="Go To This Product's Detailed Information" title=" Go To This Product's Detailed Information " width="56" height="26"/></a></div>
</div>
</div>
</div></div>
<div class="centerBoxContentsFeatured centeredContent back" style="width:33%;"><div class="product-col" style="margin-left:20px;">
<div class="img">
<a href="#1_31&3812up9agstjhkpt4e3n5t23.htm" ><img src="images/03.jpg"  alt="Amet consectetur set magna" title=" Amet consectetur set magna " width="181" height="135"/></a>
</div>
<div class="prod-info">
<a class="name" href="#1_31&3812up9agstjhkpt4e3n5t23.htm" >Amet consectetur set magna</a>
<div class="wrapper">
<div class="price">
<strong>$241.00</strong>
</div>
<div class="button"><a href="#1_31&3812up9agstjhkpt4e3n5t23.htm" ><img src="img/button_goto_prod_details.png"  alt="Go To This Product's Detailed Information" title=" Go To This Product's Detailed Information " width="56" height="26"/></a></div>
</div>
</div>
</div></div>
<br class="clearBoth"/>
<div class="centerBoxContentsFeatured centeredContent back" style="width:33%;"><div class="product-col">
<div class="img">
<a href="#1_31&4812up9agstjhkpt4e3n5t23.htm" ><img src="images/04.jpg"  alt="Amet consectetur dolor lorem donec" title=" Amet consectetur dolor lorem donec " width="181" height="135"/></a>
</div>
<div class="prod-info">
<a class="name" href="#1_31&4812up9agstjhkpt4e3n5t23.htm" >Amet consectetur dolor lorem donec</a>
<div class="wrapper">
<div class="price">
<strong>$651.00</strong>
</div>
<div class="button"><a href="#1_31&4812up9agstjhkpt4e3n5t23.htm" ><img src="img/button_goto_prod_details.png"  alt="Go To This Product's Detailed Information" title=" Go To This Product's Detailed Information " width="56" height="26"/></a></div>
</div>
</div>
</div></div>
<div class="centerBoxContentsFeatured centeredContent back" style="width:33%;"><div class="product-col" style="margin-left:10px; margin-right:0px;">
<div class="img">
<a href="#2&5812up9agstjhkpt4e3n5t23.htm" ><img src="images/05.jpg"  alt="Dolor sit amet consectetur set magna" title=" Dolor sit amet consectetur set magna " width="181" height="135"/></a>
</div>
<div class="prod-info">
<a class="name" href="#2&5812up9agstjhkpt4e3n5t23.htm" >Dolor sit amet consectetur set magna</a>
<div class="wrapper">
<div class="price">
<strong>$211.00</strong>
</div>
<div class="button"><a href="#2&5812up9agstjhkpt4e3n5t23.htm" ><img src="img/button_goto_prod_details.png"  alt="Go To This Product's Detailed Information" title=" Go To This Product's Detailed Information " width="56" height="26"/></a></div>
</div>
</div>
</div></div>
<div class="centerBoxContentsFeatured centeredContent back" style="width:33%;"><div class="product-col" style="margin-left:20px;">
<div class="img">
<a href="#2&6812up9agstjhkpt4e3n5t23.htm" ><img src="images/06.jpg"  alt="Название" title=" Название " width="181" height="135"/></a>
</div>
<div class="prod-info">
<a class="name" href="#2&6812up9agstjhkpt4e3n5t23.htm" >Название</a>
<div class="wrapper">
<div class="price">
<strong>$83.00</strong>
</div>
<div class="button"><a href="#2&6812up9agstjhkpt4e3n5t23.htm" ><img src="img/button_goto_prod_details.png"  alt="Go To This Product's Detailed Information" title=" Go To This Product's Detailed Information " width="56" height="26"/></a></div>
</div>
</div>
</div></div>
<br class="clearBoth"/>
</div>
</div>
<div class="clear"></div>
</div>
 
она везде разная практически мне надо понять можно ли конкретно для второго элемента сделать вывод нужного стиля!?!?!?!?!?!

Если необходимо всего лишь это, то вот код:
PHP:
{if ($smarty.foreach.item.iteration==2)}style="margin-left:10px; margin-right:0px;"{/if}

Для второй итерации цикла foreach прописывается заданный стиль.

P.S. Без обид, но рекомендовал бы как-то прокачать навык доходчиво излагать мысли :) Какая-то полнейшая абракадабра в сообщениях.
 
а еще можно использовать функцию @count
 
Назад
Сверху