Forums / Developer / Template Header Image Switch -- Need a more elegant solution

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}

eZ debug

Timing: Jan 19 2025 04:28:36
Script start
Timing: Jan 19 2025 04:28:36
Module start 'content'
Timing: Jan 19 2025 04:28:36
Module end 'content'
Timing: Jan 19 2025 04:28:36
Script end

Main resources:

Total runtime0.1423 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 589.2109180.7969
Module start 'content' 0.00670.0045 770.007893.8672
Module end 'content' 0.01120.1311 863.8750533.4219
Script end 0.1423  1,397.2969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00342.3873200.0002
Check MTime0.00140.9805200.0001
Mysql Total
Database connection0.00090.607010.0009
Mysqli_queries0.101070.92901410.0007
Looping result0.00110.78401390.0000
Template Total0.130891.910.1308
Template load0.00080.554910.0008
Template processing0.130091.321210.1300
Override
Cache load0.00060.399010.0006
Sytem overhead
Fetch class attribute can translate value0.00100.671610.0010
XML
Image XML parsing0.00030.186910.0003
General
dbfile0.00352.4925200.0002
String conversion0.00000.005530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs