CS-CART: Random banner rotation

Post

Comments   |   PHP


Litle hack to rotate many banners in one block. First of all you need to add all your banners at block, and then open this file:
/skins/THEME_NAME/customer/addons/banners/blocks/original.tpl
and replace it contents with this:

{* $Id: original.tpl 12696 2011-06-16 08:37:55Z alexions $ *}
 
{** block-description:original **}
{assign var=randomindex value=$items|@array_rand}
{foreach from=$items item="banner" key="key"}
{if $key==$randomindex}
	{if $banner.type == "G" && $banner.main_pair.image_id}
	<div class="ad-container center">
		{if $banner.url != ""}<a href="{$banner.url|fn_url}" {if $banner.target == "B"}target="_blank"{/if}>{/if}
		{include file="common_templates/image.tpl" images=$banner.main_pair object_type="common"}
		{if $banner.url != ""}</a>{/if}
	</div>
	{else}
		<div class="wysiwyg-content">
			{$banner.description|unescape}
		</div>
	{/if}
{/if}
{/foreach}

Leave a Reply