Hi Guys,
I’ve done this “widget” for the Top_Items. What it does is pick out randomly 3 of the articles in the Top Items list and displays them on the page in a sort of “widget”.
Here’s the code:
top_items.tpl:
[{assign var=topArticles value=$oView->getTop5ArticleList()}]
[{assign var=topArticles_keys value=$topArticles->arrayKeys()}]
[{php}]shuffle($this->_tpl_vars['topArticles_keys']);[{/php}]
[{section name=counter loop=$topArticles_keys max=3}]
[{assign var=_key value=$topArticles_keys[counter]}]
[{assign var=_product value=$topArticles[$_key]}]
<div class="listitem">
[{ assign var="sTop5ArtTitle" value="`$_product->oxarticles__oxtitle->value` `$_product->oxarticles__oxvarselect->value`" }]
<table>
<tr>
<td style="vertical-align:top; width:56px">
<div class="top5picture">
<a id="test_Top5Pic_[{$_product->oxarticles__oxid->value}]" href="[{$_product->getMainLink()}]" class="picture">
<img src="[{$_product->getIconUrl()}]" alt="[{ $sTop5ArtTitle|strip_tags }]" class="float_left">
</a>
</div>
</td>
<td>
<div class="top5details">
<a id="test_Top5Title_[{$_product->oxarticles__oxid->value}]" href="[{$_product->getMainLink()}]" class="title">[{ $sTop5ArtTitle|strip_tags}]</a>
<br>
[{oxhasrights ident="SHOWARTICLEPRICE"}]
[{if $_product->getFPrice()}]
[{assign var="currency" value=$oView->getActCurrency() }]
<b id="test_Top5Price_[{$_product->oxarticles__oxid->value}]">[{ $_product->getFPrice() }] [{ $currency->sign}]</b>
[{/if}]
[{/oxhasrights}]
[{*oxhasrights ident="SHOWSHORTDESCRIPTION"}]
<div class="desc"><i>[{ $_product->oxarticles__oxshortdesc->value }]</i></div>
[{/oxhasrights*}]
<div class="clear"></div>
</div>
</td>
</tr>
</table>
</div>
[{/section}]
start.tpl
...
[{ if $oView->getTop5ArticleList() }]
<div id="top5articlelist" class="forms float_right">
<div class="framed-bg" style="width:181px;"><div class="h2">Kennen Sie schon...</div></div>
<div class="startpage_products box framed" style="width:188px; padding:0px; margin-bottom:0;">
[{include file="inc/top_items.tpl" }]
<div class="clear"></div>
</div>
</div>
[{ /if }]
...
Now this works fine on the start.tpl but for some reason, and that is why I’m posting this, it woun’t work when I want to insert it into the content.tpl in the exact same way.
content.tpl
[{assign var="oContent" value=$oView->getContent()}]
[{assign var="template_title" value=$oContent->oxcontents__oxtitle->value}]
[{include file="_header.tpl" title=$template_title location=$template_title}]
[{*<h1 id="test_contentHeader" class="boxhead title">[{$template_title}]</h1>*}]
<div id="top5articlelist" class="forms float_right contentview">
<div class="framed-bg" style="width:181px;"><div class="h2">Bestseller</div></div>
<div class="startpage_products box framed" style="width:188px; padding:0px; margin-bottom:0;">
[{include file="inc/top_items.tpl"}]
<div class="clear"></div>
</div>
</div>
<div id="test_contentBody" class="box">[{ oxcontent oxid=$oView->getContentId() }]</div>
[{insert name="oxid_tracker" title=$template_title }]
[{include file="_footer.tpl" }]
Maybe I’m missing something. Any body able to help me out here?
Thx