Community Documentation

Displaying random images

Last updated August 26, 2009. Created by mr.baileys on August 24, 2005.
Edited by bekasu, Little_John, sepeck. Log in to edit this page.

This is made possible by a script found at www.alistapart.com called rotate.php.

Procedure:

  1. Create a directory under the web server's document root. I placed it under my theme's directory.
  2. Populate that directory with images.
  3. Download script and put it in a nice resting place.
  4. Edit script so it can find your image directory. To avoid editing you can just place the script in the same directory as the images.
  5. Under your theme's config, for custom logo, instead of a path to an image use the path to the script.
  6. You're done.

Comments

Added swfs and called from theme code

I love this code, thank you. It worked quickly & easily. I also added this line to the php to enable rotating swfs:

$extList['swf'] = 'application/x-shockwave-flash';

I called it from my theme page.tpl.php as follows:

  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="263" height="150" align="top" title="fluidit solutions videos">
<param name="movie" value="<?php print $front_page . $directory; ?>/videos/rotate.php">
    <param name="quality" value="high"><param name="LOOP" value="false">
    <embed src="<?php print $front_page . $directory; ?>/videos/rotate.php" width="263" height="150" loop="false" align="top" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
  </object>

is not enough to add the line in rotate.php?

i tried to doing like this but it didnt work..

I am not an expert with the code, so do you think your code could work for me? of course changiung some paths...

doesnt work

Do I have to enable something else?

I put images and script in same folder, but no images show up.

Just found the answer

http://drupal.org/node/641914

answer

paste code to your page.tpl i sure your problem has solved

<?php
print $head_title
?>

<?php
print $head
?>

<?php
print $styles
?>

@import "
<?php
print base_path() . path_to_theme()
?>
/master_reset.css";

@import "

<?php
print base_path() . path_to_theme()
?>
/fix-ie6.css";

<?php
print $scripts
?>

<?php
/* Needed to avoid Flash of Unstyle Content in IE */
?>

Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/bg2.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/bg2.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/primary.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/search_box.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/top_bar.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/footer_wood.jpg" alt="" />

<?php
if (isset($secondary_links)) :
?>

<?php
print theme('links', $secondary_links, array('class' => 'links secondary-links'))
?>

<?php
endif;
?>

<?php
print theme_get_setting('admire_grunge_feed_url');
?>
" rel="nofollow">Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/rss.png" alt="Rss Feed" title="Subscribe to updates via RSS" />

<?php
if (!($user->uid)) { print login_register_links(); } else { echo  admire_grunge_welcome_user(); }
?>

<?php
if ($logo) {
?>
<?php
print $base_path
?>
" title="
<?php
print t('Home')
?>
" rel="nofollow">Only local images are allowed.<?php
print $logo
?>
" alt="
<?php
print t('Home')
?>
" />
<?php
}
?>

<?php
if($site_name || $site_slogan) {
?>

<?php
if ($site_name) {
?>
<?php
print $base_path
?>
" title="
<?php
print t('Home')
?>
" rel="nofollow">
<?php
print $site_name
?>
<?php
}
?>

<?php
if ($site_slogan) {
?>
<?php
print $site_slogan
?>
<?php
}
?>

<?php
}
?>

<?php
if ($search_box){
?>

<?php
 
print $search_box;
?>

<?php
}
?>

<?php
if (isset($primary_links)) :
?>

<?php
print menu_tree($menu_name = variable_get('menu_primary_links_source', 'primary-links'));
?>

<?php
endif;
?>

<?php
if($main_banner){
?>

<?php
print $main_banner;
?>

<?php
}
?>

<?php
if($sidebar_first) {
?>

Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/left_top.jpg" alt="" />

<?php
 
print $sidebar_first ;
?>

Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/left_bottom.png" alt="" />

<?php
}
?>

<?php
if($above_content_ad){
?>

<?php
print $above_content_ad;
?>

<?php
}
?>

<?php
if($content_top) {
?>

<?php
print $content_top;
?>

<?php
}
?>

<?php
if ($mission): print '<div id="mission">'. $mission .'</div>'; endif;
?>

<?php
if($breadcrumb){
?>
<?php
print $breadcrumb
?>
<?php
}
?>

<?php
if($title){
?>
<?php
print $title
?>
<?php
}
?>

<?php
if($tabs){
?>
<?php
print $tabs
?>
<?php
}
?>

<?php
if ($show_messages) { print $messages; }
?>

<?php
if($help){
?>
<?php
print $help
?>
<?php
}
?>

<?php
print $content;
?>

<?php
print $feed_icons
?>

<?php
if($content_bottom) {
?>

<?php
print $content_bottom;
?>

<?php
}
?>

<?php
if($right_dark || $sidebar_last) {
?>

<?php
if($right_dark){
?>

<?php
 
print $right_dark ;
?>

<?php
}
?>

<?php
if($right_ad){
?>

<?php
print $right_ad;
?>

<?php
}
?>

<?php
if($sidebar_last){
?>

<?php
 
print $sidebar_last ;
?>

<?php
}
?>

<?php
}
?>


<?php
print $footer_message
?>

All Rights reserved Logimindz Technologies, Disclaimer.

<?php
print $footer
?>

Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/comment_form_mat.gif" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/comment_hanger.gif" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/comment_paper.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/comment_paper_bottom.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/comment_paper_top.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/content_block_bg.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/content_block_top.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/left.jpg" alt="" />
Only local images are allowed.<?php
print base_path() . path_to_theme()
?>
/images/right_top.jpg" alt="" />

<?php
print $closure
?>

About this page

Audience
Themers

Theming Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.