How can this php code in template code ?!

Author Message

Selmah Maxim

Thursday 31 July 2003 4:14:40 am

if($a%2)
{
...
}
elseif($a%4)
{
...
}
elseif($a%6)
{
...
}
else
{
...
}

?!

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:33:36
Script start
Timing: Jan 18 2025 19:33:36
Module start 'layout'
Timing: Jan 18 2025 19:33:36
Module start 'content'
Timing: Jan 18 2025 19:33:37
Module end 'content'
Timing: Jan 18 2025 19:33:37
Script end

Main resources:

Total runtime0.6747 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 588.0313152.6406
Module start 'layout' 0.00670.0029 740.671939.4609
Module start 'content' 0.00950.6640 780.1328482.2969
Module end 'content' 0.67350.0011 1,262.429712.1406
Script end 0.6746  1,274.5703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4660160.0002
Check MTime0.00140.2052160.0001
Mysql Total
Database connection0.00140.202210.0014
Mysqli_queries0.627192.9547600.0105
Looping result0.00040.0582580.0000
Template Total0.647195.920.3236
Template load0.00240.356820.0012
Template processing0.644795.558320.3224
Template load and register function0.00010.013010.0001
states
state_id_array0.00070.106710.0007
state_identifier_array0.00090.135820.0005
Override
Cache load0.00200.3029560.0000
Sytem overhead
Fetch class attribute can translate value0.00030.048620.0002
Fetch class attribute name0.00080.125340.0002
XML
Image XML parsing0.00020.031020.0001
class_abstraction
Instantiating content class attribute0.00000.001440.0000
General
dbfile0.00060.0904100.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs