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:
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 would usually return the path, now it simply doesn't work.
Any ideas?
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();
Any ideas?
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):
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 ;-))