Hi,
I utilise responsiveslide library to show sliding news with fade-in/out every 5 second.
So, I wish to update the content of news div every minute but my code doesn’t work:
views/layout/slideshow.php
<?php /* @var $this Controller */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/slideshow.css" />
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>
<body>
<div class="container" id="page">
<?php echo $content; ?>
<div class="clear"></div>
</div><!-- page -->
<div id="footer">
<?php
// link dell'RSS
$news = new News();
echo $news->run();
?>
</div>
<?php
$refreshInterval = Yii::app()->params['newsRefreshInterval'];
Yii::app()->clientScript->registerScript('feed-updater', '
function updater() {
$("#footer").load(" #footer", function(){
setTimeout(updater, '.$refreshInterval.');
});
}
setTimeout(updater, '.$refreshInterval.');
');
?>
</body>
</html>
Class News returns news in a ‘ul’ list
Finally, this is the javascript code:
function responsiveText()
{
$('#footer').css('font-size', $('#footer').css('height'));
}
// call responsiveSlides() lib
$(function()
{
// image slideshow
$("#imageSlider").responsiveSlides(
{
// 20 sec
timeout: 20000,
});
// news slideshow
$("#newsSlider").responsiveSlides(
{
// 3 sec
timeout: 5000,
});
responsiveText();
// resposive news
$(window).resize(function(){
responsiveText();
});
});
After the first refresh the news are stopped and only the first news of the list is showed.