Forum Moderators: coopster
I really hope you can help me with this as I've been tearing my hair out trying to work out how to implement this.
Below is the code for a JQuery + Jquery Innerfade plugin image rotator combined with PHP. I've included both Jquery files in the head of my page and they are working according to some quick tests I did by hard-coding the image url.
However, I'm trying to load the images found in a specific directory of a Joomla installation (hence the Joomla '$this->baseurl' call) and the <li> isn't being generated for some reason. I believe it's to do with the $image_relative_path not being set right, but everything I try doesn't seem to work.
Any ideas on how I can get this working?
Thanks
<?php
// Global Variables
$image_dir = $this->baseurl . '/templates/name/images/home'; // directory on server
$image_relative_path = '/images/home'; // path to images relative to THIS script
$file_types = array('jpg','jpeg','gif','png');
$image_time = '4000'; // seconds each image will display (4000 = 4 seconds)if($handle = opendir($image_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$ext_bits = explode(".",$file);
foreach($ext_bits as $key => $value){
if(in_array($value,$file_types)){
$image_rotation .= '<li><img src="'.$image_relative_path.'/'.$file.'"></li>';
}
}
}
}
// Close the directory
closedir($handle);
}?>
<script type="text/javascript">
$(document).ready(function() {
$('#image_rotate').innerfade({
speed: 'slow',
timeout: 4000,
type: 'sequence',
containerheight: '220px'
});
});</script>
<ul id="image_rotate" style="list-style: none;">
<?php $image_rotation; ?>
</ul>