Page 1 of 1

Banner rotator - doladenie sablony

Posted: Sat Sep 22, 2012 10:51 am
by Joseph777
Zdravim

v CMSMS som vymyslel sablonu pre rotovanie banerov respektive content blokov vid nizsie

Mam ale problem: ked je napr. content block banner_1 banner_2 a banner_3 prazdny a vyplneny je content block banner_4 a banner_5
a {capture assign='banner'}banner_{1|rand:5}{/capture} vygeneruje cislo od 1 do 3 vzdy sa zobrazi banner podla tejto podmienky
{elseif $banner_4}
{$banner_4}
{else}
teda banner_4
to znamena ze banner_4 bude zobrazovat pri vygenerovanom cisle 1,2,3,4 a teda sa bude zobrazovat omnoho castejsie ako banner_5
(tento problem nie je pokial su vsetky content blocky teda banner_1 az 5 vyplnene)

Neda sa to nejako vyriesit aby banneri zobrazovalo uplne nahodne a skoro rovnomerne?

Code: Select all

{content block='banner_1' assign='banner_1' label='1. Banner' wysiwyg='false'}
{content block='banner_2' assign='banner_2' label='2. Banner' wysiwyg='false'}
{content block='banner_3' assign='banner_3' label='3. Banner' wysiwyg='false'}
{content block='banner_4' assign='banner_4' label='4. Banner' wysiwyg='false'}
{content block='banner_5' assign='banner_5' label='5. Banner' wysiwyg='false'}

{capture assign='banner'}banner_{1|rand:5}{/capture}

<div>
{if $banner_1 and $banner == 'banner_1'}
{$banner_1}
{elseif $banner_2 and $banner == 'banner_2'}
{$banner_2}
{elseif $banner_3 and $banner == 'banner_3'}
{$banner_3}
{elseif $banner_4 and $banner == 'banner_4'}
{$banner_4}
{elseif $banner_5 and $banner == 'banner_5'}
{$banner_5}
{else}
{if $banner_1}
{$banner_1}
{elseif $banner_2}
{$banner_2}
{elseif $banner_3}
{$banner_3}
{elseif $banner_4}
{$banner_4}
{else}
{$banner_5}
{/if}
{/if}
</div>

Re: Banner rotator - doladenie sablony

Posted: Tue Oct 09, 2012 7:46 pm
by kuzmany
Skusil by som konstrukciu while:

http://www.smarty.net/docs/en/language. ... .while.tpl

Code: Select all

{while trim($banner) != ''}
{capture assign='banner'}banner_{1|rand:5}{/capture}
{/while}

Re: Banner rotator - doladenie sablony

Posted: Wed Oct 10, 2012 5:53 pm
by Joseph777
kuzmany wrote:Skusil by som konstrukciu while:

http://www.smarty.net/docs/en/language. ... .while.tpl

Code: Select all

{while trim($banner) != ''}
{capture assign='banner'}banner_{1|rand:5}{/capture}
{/while}
myslis takto? a co znamena to trim pri while?

Code: Select all

{content block='banner_1' assign='banner_1' label='1. Banner' wysiwyg='false'}
{content block='banner_2' assign='banner_2' label='2. Banner' wysiwyg='false'}
{content block='banner_3' assign='banner_3' label='3. Banner' wysiwyg='false'}
{content block='banner_4' assign='banner_4' label='4. Banner' wysiwyg='false'}
{content block='banner_5' assign='banner_5' label='5. Banner' wysiwyg='false'}

<div>
{while trim($banner) != ''}
{capture assign='banner'}banner_{1|rand:5}{/capture}
{/div}