Create a template file.
Let's call it random.phtml
.
Put it in app/design/frontend/base/default/template/random/random.phtml
.
The contents should look something like this:
<?php
$images = array('img1.png', 'img2.png', ....);
shuffle($images);
$image = $images[0];
$url = Mage::getBaseUrl('media').'path/to/folder/'.$image;
?>
<img src="<?php echo $url?>" alt="" />
make sure you put all your images in media/path/to/folder
. (feel free to change the name of the folder).
Now you can use this in 3 ways.
Either inside a static block:
{{block type="core/template" template="random/random.phtml"}}
either in any other template:
$block = Mage::app()->getLayout()->createBlock('core/template')->setTemplate('random/random.phtml');
$html = $block->toHtml();
echo $html;
either in a layout file:
<reference name="left"><!-- not necessarily left. can be right, content, header... -->
<block type="core/template" template="random/random.phtml" name="random-image" as="random-image" />
</reference>
Best Answer
Create one
.phtml
file insideapp/design/frontend/your_theme/default/template/catalog
lets name it ashomecategories.phtml
and paste this code into itnow create a static block lets name it as
homecategories
id ashome_categories
and now place this code into content of that block{{block type="core/template" template="catalog/homecategories.phtml"}}
now call this static block in yourcms.xml
in this way