Template Header Image Switch -- Need a more elegant solution

Author Message

Kenneth Colwell

Monday 23 February 2004 7:40:16 am

I've created the following two switch statements to allow a customer header image to be shown on the top of both folders and articles.
However, it seems like there should be an easier way to accomplish this if I fully comprehended the template syntax.

Does anyone have any ideas on how to make this work better? I'm specifically looking to not double the lists of image tags since this will become a very large list.

Thanks,
Ken Colwell

{let y=$node.object.class_name}
{switch match=$y}
{* if class name equals Article use parent_node to select the correct image tag *}
{case match=array(Article)|contains($y)}
{let x=$node.object.main_parent_node_id}
{switch match=$x}
{case match=array(3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037)|contains($x)}
{let elements=array('football', 'football2', 'football3', 'football4')|shuffle}
<img src="/design/muc/images/header_images/{$elements[0]}.jpg" width="589" height="140" border="0" alt="" />
{/let}
{/case}
{case match=array(2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3075, 3076, 3077)|contains($x)}
{let elements=array('womens_track', 'womens_tennis', 'womens_swimming', 'womens_swimming2', 'womens_soccer', 'womens_cross', 'volley_ball', 'softball', 'softball2', 'quad', 'mens_track', 'mens_tennis', 'mens_tennis2', 'mens_swimming', 'mens_swimming2', 'mens_golf', 'mens_golf4', 'mens_golf3', 'mens_golf2', 'mens_cross', 'football', 'football4', 'football3', 'football2', 'baseball', 'baseball4', 'baseball3', 'baseball2')|shuffle}
<img src="/design/muc/images/header_images/{$elements[0]}.jpg" width="589" height="140" border="0" alt="" />
{/let}
{/case}
{case}
{let elements=array('beegley_pano', 'chapel_pano', 'dorms_pano', 'garden_pano', 'hpcc_pano', 'khic_pano', 'students_quad_pano', 'students_walking_pano', 'quad')|shuffle}
<img src="/design/muc/images/header_images/{$elements[0]}.jpg" width="589" height="140" border="0" alt="" />
{/let}
{/case}
{/switch}
{/let}
{/case}
{* if class name does not equal Article use node_id to select the correct image tag *}

{case}
{let x=$node.node_id}
{switch match=$x}
{case match=array(3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037)|contains($x)}
{let elements=array('football', 'football2', 'football3', 'football4')|shuffle}
<img src="/design/muc/images/header_images/{$elements[0]}.jpg" width="589" height="140" border="0" alt="" />
{/let}
{/case}
{case match=array(2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3075, 3076, 3077)|contains($x)}
{let elements=array('womens_track', 'womens_tennis', 'womens_swimming', 'womens_swimming2', 'womens_soccer', 'womens_cross', 'volley_ball', 'softball', 'softball2', 'quad', 'mens_track', 'mens_tennis', 'mens_tennis2', 'mens_swimming', 'mens_swimming2', 'mens_golf', 'mens_golf4', 'mens_golf3', 'mens_golf2', 'mens_cross', 'football', 'football4', 'football3', 'football2', 'baseball', 'baseball4', 'baseball3', 'baseball2')|shuffle}
<img src="/design/muc/images/header_images/{$elements[0]}.jpg" width="589" height="140" border="0" alt="" />
{/let}
{/case}
{case}
{let elements=array('beegley_pano', 'chapel_pano', 'dorms_pano', 'garden_pano', 'hpcc_pano', 'khic_pano', 'students_quad_pano', 'students_walking_pano', 'quad')|shuffle}
<img src="/design/muc/images/header_images/{$elements[0]}.jpg" width="589" height="140" border="0" alt="" />
{/let}
{/case}
{/switch}
{/let}
{/case}
{/switch}
{/let}

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 19 2025 00:30:12
Script start
Timing: Jan 19 2025 00:30:12
Module start 'layout'
Timing: Jan 19 2025 00:30:12
Module start 'content'
Timing: Jan 19 2025 00:30:13
Module end 'content'
Timing: Jan 19 2025 00:30:13
Script end

Main resources:

Total runtime0.8879 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 589.2891152.6563
Module start 'layout' 0.00550.0025 741.945339.5078
Module start 'content' 0.00790.8784 781.4531427.6719
Module end 'content' 0.88640.0015 1,209.125012.0938
Script end 0.8878  1,221.2188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.3421160.0002
Check MTime0.00130.1444160.0001
Mysql Total
Database connection0.00070.077010.0007
Mysqli_queries0.830093.4848460.0180
Looping result0.00060.0633440.0000
Template Total0.844395.120.4222
Template load0.00210.233820.0010
Template processing0.842294.858320.4211
Template load and register function0.00020.025710.0002
states
state_id_array0.00080.095610.0008
state_identifier_array0.00210.233920.0010
Override
Cache load0.00170.1952560.0000
Sytem overhead
Fetch class attribute can translate value0.00090.098910.0009
Fetch class attribute name0.00090.098110.0009
XML
Image XML parsing0.00010.016210.0001
class_abstraction
Instantiating content class attribute0.00000.000610.0000
General
dbfile0.00070.0740100.0001
String conversion0.00000.000840.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
1content/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
4content/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: 11
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs