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.