Share » Forums » Developer » How can this php code in template...

How can this php code in template code ?!

How can this php code in template code ?!

Thursday 31 July 2003 4:14:40 am - 3 replies

Author Message

Paul Forsyth

Thursday 31 July 2003 4:47:36 am

Would this do? A bit mangled but it should give you the basic if-then-else structure.

Dots used for indentation...

{section show=mod($a,2)}
.....{section show=mod($a,4)}
..........{section show=mod($a,6)}

..........{section-else}

..........{/section}

.....{section-else}

.....{/section}

{section-else}

{/section}

Selmah Maxim

Thursday 31 July 2003 7:34:07 am

The idea of this to load random image or random template !
Not sure but maybe will work this way :

{let
sec=$date|datetime(custom,"%i")
}
{section show=mod($sec,2)}
{include uri="layout1.tpl"}
{section-else show=mod($sec,4)}
{include uri="layout2.tpl"}
{section-else show=mod($sec,6)}
{include uri="layout3.tpl"}
{section-else show=mod($sec,8)}
{include uri="layout4.tpl"}
{section-else}
{include uri="layout4.tpl"}
{/section}

So, this code should be in your design/templates/pagelayout.tpl

I cann`t test now, but what you think ?!

Paul Forsyth

Thursday 31 July 2003 10:05:31 am

If you want to load something random then its perhaps better not to use multiple sections otherwise you need to add lots of them!

If you have images then perhaps just add some number based on the current time to the imagename, i.e. {concat("imagename", $myRandomNumber,".jpg")}. The same could apply to templates. This means you must prepare the files on the system.

You could also allow the php 'rand' function through and call it with parameters that define the range of the random number. With this you can make sure you have the right number of images/templates to switch between.

paul

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu