3212 Posts in 847 Topics by 809 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1176 Views |
-
Advice on making a banner template

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() {
parent::init();
Director::redirect(Director::baseURL());
}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.
Thanks.
-
Re: Advice on making a banner template

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. http://doc.silverstripe.org/doku.php?id=modules:dataobjectmanager
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.
Aaron.
-
Re: Advice on making a banner template

28 November 2009 at 1:01am Last edited: 28 November 2009 1:02am
There is some banner stuff on http://ssbits.com/working-with-banners/
Not sure if it'll help though.
| 1176 Views | ||
|
Page:
1
|
Go to Top |



