Commit 49911bed authored by christian.zenker's avatar christian.zenker

made randombanners cachable


git-svn-id: http://svn.t3o.typo3.org/extensions/projects/t3org/randombanners/trunk@2282 e8cb78a8-64f2-4011-8042-bd1ea5058d47
parent 8dbd5810
......@@ -69,12 +69,11 @@ class Tx_Randombanners_Controller_BannerController extends Tx_Extbase_MVC_Contro
/**
* Displays all Statistics
*
* @param integer $numberOfBannersShown
* @return void
*/
public function listAction($numberOfBannersShown=0) {
public function listAction() {
// initialization
$banners = $this->bannerRepository->findRandomBanners();
$banners = $this->bannerRepository->findAll();
foreach ($banners as $banner) {
if (!($banner->getLogo() instanceof Tx_Extbase_Domain_Model_Dam)) {
......@@ -82,7 +81,7 @@ class Tx_Randombanners_Controller_BannerController extends Tx_Extbase_MVC_Contro
}
// increment the displayed counter
$banner->setDisplayedThisMonth($banner->getDisplayedThisMonth() + 1); // seems rather useless when caching is enabled
// $banner->setDisplayedThisMonth($banner->getDisplayedThisMonth() + 1); // seems rather useless when caching is enabled
}
$this->view->assign('banners', $banners);
}
......
......@@ -8,7 +8,8 @@ plugin.tx_randombanners {
storagePid = {$plugin.tx_randombanners.persistence.storagePid}
}
settings {
numberOfBannersShown = 6
numberOfBannersShown = 0
pid = {$const.page.root}
}
}
......
<div id="randombanners">
<span style="display: none;" id="randombannersNumber">{settings.numberOfBannersShown}</span>
<span style="display: none;" id="randombannersUrl"><f:uri.action action="list" pageType="69" pageUid="{settings.pid}" /></span>
</div>
\ No newline at end of file
......@@ -11,7 +11,16 @@ function clickBanner(el) {
function initBanners() {
/* platin members at the left navigation */
if($(".d.navigationbanners .tx-randombanners").length > 0) {
$(".d.navigationbanners .tx-randombanners-item").each(function(){
var container = $('#randombanners .tx-randombanners');
var banners = $(".d.navigationbanners .tx-randombanners-item");
var numBanners = banners.length;
for(var i=0; i< 4; i++) {
var banner = banners[Math.floor(Math.random() * numBanners)];
container.prepend(banner);
}
banners.each(function(){
if($(this).index() > 1)
$(this).css("display","none");
});
......@@ -82,7 +91,7 @@ $(document).ready(function() {
if($('#randombannersNumber')) {
// if: load via ajax should be done
$.ajax({
url: '/index.php?type=69&tx_randombanners_list[action]=list&tx_randombanners_list[controller]=Banner&tx_randombanners_list[numberOfBannersShown]=' + parseInt($('#randombannersNumber').html()),
url: $('#randombannersUrl').text(),
success: function(html) {
$('#randombanners').append(html);
initBanners();
......
......@@ -11,7 +11,7 @@
),
array(
'Banner' => 'list,show',
'Banner' => 'show',
)
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment