Random SWF Select

I am hoping someone will be able to help, I have tryed for hours using code snippents and all sorts but am not making any progress /

I use zencart 1.5.0 as my online store and I need to edit the main header on the main page. This is set to display one flash file in perticular. I want it to randomly select and display one. (i.e. there are 5 flash files in my online folder, when the screen is refreshed/ loaded it will randomly pick one and display it)

Here is the code currently (to save you reading the main bit is at the bottem):
[php]
======START======

<?php /** * Common Template - tpl_header.php * * this file can be copied to /templates/your_template_dir/pagename
* example: to override the privacy page
* make a directory /templates/my_template/privacy
* copy /templates/templates_defaults/common/tpl_footer.php to /templates/my_template/privacy/tpl_header.php
* to override the global settings and turn off the footer un-comment the following line:
*
* $flag_disable_header = true;
* * @package templateSystem * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: tpl_header.php 4813 2006-10-23 02:13:53Z drbyte $ */ ?> <?php // Display all header alerts via messageStack: if ($messageStack->size('header') > 0) { echo $messageStack->output('header'); } if (isset($_GET['error_message']) && zen_not_null($_GET['error_message'])) { echo htmlspecialchars(urldecode($_GET['error_message'])); } if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) { echo htmlspecialchars($_GET['info_message']); } else { } ?> <?php if (!isset($flag_disable_header) || !$flag_disable_header) { ?>
<?php echo HEADER_TITLE_CATALOG; ?> <?php if ($_SESSION['customer_id']) { ?>

 |  <?php echo HEADER_TITLE_LOGOFF; ?>
 |  <?php echo HEADER_TITLE_MY_ACCOUNT; ?>

<?php } else { if (STORE_STATUS == '0') { ?>

 |  <?php echo HEADER_TITLE_LOGIN; ?>

<?php } } ?> <?php if ($_SESSION['cart']->count_contents() != 0) { ?>

 |  <?php echo HEADER_TITLE_CART_CONTENTS; ?>
 |  <?php echo HEADER_TITLE_CHECKOUT; ?>

<?php } ?>
<?php if ($_SESSION['cart']->count_contents() == 0) { $cart_text = 'now in your cart ' . $_SESSION['cart']->count_contents() . ' items'; } elseif ($_SESSION['cart']->count_contents() == 1) { $cart_text = 'now in your cart ' . $_SESSION['cart']->count_contents() . ' item'; } else {

}
?>
<?php echo BOX_HEADING_SHOPPING_CART;?>: <?php echo $cart_text ?>

<?php if (EZPAGES_STATUS_HEADER == '1' or (EZPAGES_STATUS_HEADER == '2' and (strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])))) { ?> <?php require($template->get_template_dir('tpl_ezpages_bar_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_ezpages_bar_header.php'); ?> <?php } ?>
<?php echo zen_draw_form('quick_find_header', zen_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');?>
<?php echo zen_draw_hidden_field('main_page',FILENAME_ADVANCED_SEARCH_RESULT); echo zen_draw_hidden_field('search_in_description', '1') . zen_hide_session_id(); ?> <?php echo zen_draw_input_field('keyword', ''.BOX_HEADING_SEARCH.'', 'class="input1" onblur="if(this.value==\'\') this.value=\'' . BOX_HEADING_SEARCH . '\'" onfocus="if(this.value ==\'' . BOX_HEADING_SEARCH . '\' ) this.value=\'\'"');?> <?php echo zen_image_submit ('search.gif', HEADER_SEARCH_BUTTON);?>
<?php require($template->get_template_dir('tpl_modules_categories_tabs.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_categories_tabs.php'); ?>
<?php if($this_is_home_page){ ?>
FAIL (the browser should render some flash content, not this).
<?php } ?>
<?php } ?>

[/php]
======END======

The file that is currently displayed is [php]<?php echo DIR_WS_TEMPLATE ?>flash/header_v8.swf" />[/php] this is the one that I need/ want to randomly change (header_v7.swf)

Any help would be appreciated. )

<?php echo DIR_WS_TEMPLATE ?>flash/header_v<?php echo rand(1,8);?>.swf" />

The lower number in rand will be the lowest number in your file names and the highest one will be the highest number in your file names. For example, if you have v1 through v8 the values I had would work. If you had v3-v9 however, you would need to change that to

<?php echo DIR_WS_TEMPLATE ?>flash/header_v<?php echo rand(3,9);?>.swf" />
Sponsor our Newsletter | Privacy Policy | Terms of Service