Rotating images Options
jonmjones
Posted: Friday, November 30, 2007 1:37:42 PM
Rank: Enthusiast

Joined: 11/26/2007
Posts: 17
A site we are developing requires images on the home page to swap depending on a set time, so image one runs for December, then image two runs for 2 weeks in jan, and image default shows when no other image should be showing. Whats the best way to approach this using umbraco please?
drobar
Posted: Friday, November 30, 2007 3:01:34 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,698
Location: KY, USA
If you have only a single image to display and it changes only rarely, you could put a mediapicker property on the homepage document type and have the website editor change it as needed. That would be simplest.

Alternatively, you could create an xslt macro that tries to do things for you. That is more robust, but would require more work to create than would probably be saved.

In any event, somebody is going to have to tell umbraco what image to use between which dates.

If you want to look into the macro approach, tell us a bit more about the scenario and we'll do our best to offer guidance.

cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
jonmjones
Posted: Friday, November 30, 2007 3:59:50 PM
Rank: Enthusiast

Joined: 11/26/2007
Posts: 17
Thanks for your help.

This is the scenario - client runs monthly campaigns, during which they want a panel (currently a static image) to change from the default image to the campaign image relevent at the time. They want to schedule these well in advance and not worry about putting them live at the correct time etc.

bootnumlock
Posted: Friday, November 30, 2007 4:23:45 PM

Rank: Fanatic

Joined: 10/9/2006
Posts: 419
you could put a datePicker(s) on the image media type and use the leftMedia picker [search for drag and drop on the forum]

Then you could use xslt to place the image that falls in the correct date range... granted, i have not done this, but now that you get me thinking -- i may :)

if i generate some code quickly (yeah, like that would ever happen) i will post here as soon as i get it working.

bootnumlock - aka bob baty-barr [http://www.baty-barr.com]
Level 1 Certified!
drobar
Posted: Friday, November 30, 2007 4:32:38 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,698
Location: KY, USA
Here's one way to handle that (among many... umbraco is very flexible!)

Create a new document type called "promotion" (or some such) and give it at least three properties: an upload field (for the image to use with this promotion), and two date pickers (for the date to start the promotion and the date to end the promotion).

Create a content node called "Promotions" (or some such). This node doesn't need a template because it will never be shown directly. This will be based on the "promotion" document type.

Put your default promotional image in the "Promotions" content node. The start and end dates don't need to be set. This image will be used unless another promotion is current.

Beneath the Promotions node, create additional nodes of doctype promotion. Each of these will have an image and start/end dates according to the promotion.

Users will be able to create/modify promotions easily this way and you won't have to be involved later :o)


Next, create an XSLT macro that takes a ContentTree parameter. When you insert the macro into your template, select the Promotions content node, which is where all the promotions data is stored.

Inside the XSLT file, cycle through all the nodes in the promotions area, sorted by end date. If the end date is equal to "today" or higher, check the start date to see if it has begun yet. If so, show the associated image from that node. If no promotions are active, show the image from the top node.

Umbraco has some date handling functions built-in, and the EXSLT methods have some more.


cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
jonmjones
Posted: Friday, November 30, 2007 5:26:15 PM
Rank: Enthusiast

Joined: 11/26/2007
Posts: 17
thanks, i'll give this a go and post my progress
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.