Hardcoded block - how to refer to custom templates installed by another package?
I've just purchased the RSS ticker addon, and I want to hard-code it into my template. The trouble is, I can't seem to refer to the custom templates that the block has created.
Here's my code:
<?php $newsticker = BlockType::getByHandle('rss_displayer'); $newsticker->controller->itemsToDisplay = 5; $newsticker->controller->showSummary = 0; $newsticker->controller->launchInNewWindow = 0; $newsticker->controller->url = "http://feeds.feedburner.com/MyRSSfeed"; $newsticker->render('ticker'); /* the problem is here */ ?>
It doesn't seem to be 'finding' the RSS ticker templates, which are in /packages/ticker/blocks/rss_displayer/templates, rather than the usual /blocks/rss_displayer/templates/
Anyone got any ideas how to sort this?
/packages/ticker/ /packages/ticker/blocks/ /packages/ticker/blocks/page_list /packages/ticker/blocks/page_list/templates /packages/ticker/blocks/page_list/templates/ticker /packages/ticker/blocks/rss_displayer /packages/ticker/blocks/rss_displayer/templates/ /packages/ticker/blocks/rss_displayer/templates/ticker/
The template I want to use is in the /packages/ticker/blocks/rss_displayer/templates/ticker/. The problem seems to be that when I hard-code the RSS Displayer into my theme, it can't 'see' the new custom template that was added by the Ticker addon. I've tried copying the contents of /packages/ticker/blocks/rss_displayer/templates/ticker to /blocks/rss_displayer/templates, but that doesn't work either.
There's obviously some problem with the syntax of the code I'm using to hardcode it into the template, because if I add an RSS Displayer in the usual WYSIWYG way, I can choose the Ticker custom template without any trouble.
But that's really weird that it won't work even when you copy the templates to your own site's blocks directory -- I would try this again and make sure you have the right paths (and are calling the render function with 'templates/ticker', not just 'ticker').
A bit hacky, but at least it's working!