HI Jak,
thx for fast reply. I struggled a bit with code and it works finally. The problem was that after I made the changes, nothing really happend. I changed a bit HomePage.ss and newsrotation.js and it's ok.
This is my whole code:
//HomePage.ss
<div id="hcontent">
<div id="hcontent" class="linia1">
<div id="hcontent" class="komorka1">
</div>
<div id="hcontent" class="komorka2">
<div id="hcontent" class="baner">
</div>
<div id="hcontent" class="news">
<% if LatestNews %>
<ul id="NewsList">
<% control LatestNews %>
<div class="latest-news">
<li class="newsDateTitle" style="font-size: 1.2em"><a href="$Link" title="Czytaj wiecej o"{$Title}"">$Title</a></li>
<li class="newsDateTitle" style="color: #949a94">$Date.Nice</li>
<li class="newsSummary">$Content.FirstParagraph<br /><br /><a href="$Link" title="Czytaj wiecej o"{$Title}"">Wiecej >></a></li>
</div>
<% end_control %>
</ul>
<% end_if %>
</div>
</div>
</div>
</div>
// HomePage.php
<?php
/**
* Defines the HomePage page type
*/
class HomePage extends Page {
static $db = array(
);
static $has_one = array(
);
/* part changing icon in admin panel for 'home' */
static $icon = "themes/tutorial/images/treeicons/home";
}
class HomePage_Controller extends Page_Controller {
/*Function LatesNews simply runs a database query that gets the latest news articles
from the database. By default, this is five, but you can change it by passing a
number to the function. */
function LatestNews($num=2) {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}
function results($data, $form){
$data = array(
'Results' => $form->getResults(),
'Query' => $form->getSearchQuery(),
'Title' => 'WYNIKI WYSZUKIWANIA'
);
$this->Query = $form->getSearchQuery();
return $this->customise($data)->renderWith(array('Page_results', 'Page'));
}
public function init(){
parent::init();
Requirements::javascript('mysite/javascript/jquery-1.8.1.min.js');
Requirements::javascript('mysite/javascript/newsrotation.js');
}
}
// newsRotation.js
var showNews = 1;
function rotateNews(){
var newsItems = jQuery('.latest-news');
newsItems.addClass('hide');
jQuery('.latest-news:nth-child(' +showNews+')').removeClass('hide');
showNews = showNews + 1;
if(showNews > newsItems.length){
showNews = 1;
}
}
jQuery(function(){
window.setInterval(function(){rotateNews()}, 5000); //call rotate news every 5 seconds.
})
One more time many thanks for Your time.
BR
Peter