Hardcoded block - how to refer to custom templates installed by another package?

Hi all

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:

      $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?

View Replies:
jordanlev replied on at Permalink Reply
Try this:
39steps replied on at Permalink Reply
I've tried that already... doesn't work :(
c5studio replied on at Permalink Reply
What is the exact filename and location of your template file?
39steps replied on at Permalink Reply
I've installed the RSS Ticker addon (http://www.concrete5.org/marketplace/addons/ticker/) and it created the following directories:


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.
jordanlev replied on at Permalink Reply
Hmm... interesting -- I've definitely included custom templates for core blocks in packages, but I guess I've always selected them via the edit interface (by choosing "Custom Template" when clicking on a block in edit mode), not via code. This may be a bug (or shortcoming) in the system -- I know with some other things you can specify a package handle to pull items from a specific package, but I'm not sure you can do that with rendering custom block templates.

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').
39steps replied on at Permalink Reply
I've managed to sort it, by including the block using the Scrapbook then getting round the Scrapbook CSS/Javascript bug by importing the relevant files into the site's header.

A bit hacky, but at least it's working!