Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Forum Module /

Discuss the Forum Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Special Template for ForumHolder


Go to End


4 Posts   1456 Views

Avatar
DeklinKelly

Community Member, 197 Posts

10 May 2011 at 6:53am

I want to use a special template named "ForumHolderFeed.ss" if the get paramager ?feed=1 is passed.

For example, this should be rendered with ForumHolderFeed.ss:
http://www.example.com/forums/?feed=1

I tried modifying ForumHolder.php, as shown below however that does not render the data in my template.

Avatar
(deleted)

Community Member, 473 Posts

10 May 2011 at 8:09am

This is usually done using actions, so http://example.com/forums/feed would use the ForumHolder_feed.ss template file.

Getting it to consistently use ForumHolderFeed.ss for a specific get switch takes a lot more effort that most people realise. You can get it working in some cases by adding the check to an index() method, and returning $this->renderWith('ForumHolderFeed.ss'), though that won't work as soon as someone tries it on an action.

Avatar
DeklinKelly

Community Member, 197 Posts

10 May 2011 at 8:26am

Thanks, simon_w for your reply.

How can I do this with an action? Do you have some sample code I could use or a link to documentation?

Avatar
(deleted)

Community Member, 473 Posts

10 May 2011 at 8:29am

The only thing you may need to do is add the action to the $allowed_actions array. SilverStripe looks for ClassName_action.ss first when deciding which template to use.