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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Template Questions /

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

Advice on making a banner template

Go to End

4 Posts   1696 Views


Community Member, 4 Posts

27 November 2009 at 7:16am

Here is what I'm after:

My site's homepage uses JQuery to cycle through a set of banners. Each banner has a title, text, image and a link to another page within the site.

I've found two ways of doing this. The first is to add all the fields to the homepage, e.g. make a tab called Banner 1 with the four necessary fields, and repeat (Banner 2, 3, etc.). But, if I do it this way I'm limited to a set number of banners (and HomePage.php gets too messy for my liking).

What I really need is the ability to add as many banners as I want. My second approach allows this but I'm not sure if it is considered correct. Basically I've created a banner holder and a banner page. Both page types have a redirect to stop them from being visited directly:

public function init() {

I then use a control, e.g. <% control FeatureBanners %> to display them on the homepage.

Is this the best way to achieve what I'm after? Any suggestions or a better solution would be greatly appreciated.

I also couldn't get redirectPerm to work, which I'm guessing is better than redirect in this case.



Community Member, 607 Posts

27 November 2009 at 8:57am

If it were me, I'd create a Banners dataobject and create a "has_many" relationship on HomePage.

Then, use dataobjectmanager to maintain your banners on one tab on your home page.

You will be able to add as many as you want, and also manage any extra fields a banner may have, such as URL link.

Then, you can use a "FetchBanner" method on your HomePage controller that returns a random banner, or all of them, however you want.



Community Member, 119 Posts

28 November 2009 at 1:01am

Edited: 28/11/2009 1:02am

There is some banner stuff on

Not sure if it'll help though.


Community Member, 4 Posts

29 November 2009 at 11:08am

Thank you!