Slideshow block customization

Permalink
Hey all,
So I'm trying to add the Slideshow block as a permanent part of a template. Here is the code I'm using:

$bt = BlockType::getByHandle('slideshow');
$bt->controller->type = 'FILESET';
$bt->controller->playback = 'RANDOM';
$bt->controller->fsID = '2';
$bt->controller->fsName = 'Leaderboards';
$bt->render('templates/leaderboard_generator');


Its feeding a custom template I designed called leaderboard_generator.

The code from the template shows up fine when the page is rendered, but for some reason the image file set won't get populated... So, in the view, whereas
$f->getRelativePath();
would usually return the path, now it simply doesn't work.

Any ideas?

focus43
 
cgrauer replied on at Permalink Reply
cgrauer
Do you still have the problem? Is it just the "getRelativePath" function that returns nothing or are there no items at all in the $images variable?

I had this problem too: no items in $images. I found that slideshow behaves in an inappropriate way: the controller's __construct() is loaded when you create the object with BlockType::getByHandle(). The __construct() then searches and loads the files according to the fileset-ID - if there is one! But there can't be one because you assign the fileset-ID only AFTER creating the BlockType-Object, so __construct() can't find any image!

I solved the problem like this (in the page's template):
$bt = BlockType::getByHandle('slideshow');
$bt->controller->fsID = 3; # ID of the fileset to use
$bt->controller->playback = 'RANDOM';
$bt->controller->duration = 15;                    
$bt->controller->fadeDuration = 4;                    
$bt->controller->__construct($bt);
$bt->render('view');


This is what it does: before rendering the view, the cunstructor is manually called again. Now as the fsID is assigned, it can load the files. And it works.

But I fear this solution won't get the nobel prize for clean coding ;-))