Reputation: 1499
Im building an eCommerce Rails 3.1 site and need the ability to add promotions throughout the site in various places. For example, the entire content side of the homepage might display a holiday promotion during the holidays, which is essentially an HTML block. Then the product pages would have a banner at the top.
I want to be able to do something like:
= render_content(:homepage_main)
In the views and then use a web-based admin to create and manage the content that is displayed. My requirements are:
Does anyone know of a gem that does all or parts of the above?
Upvotes: 2
Views: 465
Reputation: 33954
What you're describing is essentially a partial that is rendered based on some condition (i.e. is today's date between 'x' and 'y').
I'm not aware of a gem for this, but it shouldn't be too hard to build. Just create a class called Promotion
with the following fields:
datetime start_date
datetime end_date
text html_code
string block_id
boolean active
string landing_page
The block_id
is essentially an HTML id that is used to insert the content of this Promotion
to a <div>
with a matching id. Then, in your store's layout, you put place marker <div>
tags in places that would hold promotional call outs. The active
field could be used to turn a promotion on/off (ignoring the start_date
and end_date
values).
I think that's pretty much all you would need.
To answer you list of needs:
html_code
field to whatever you wantstart_date
and end_date
fieldsviews
field for the number of times a given promotion was displayed, and a clicked
field for when it was clicked. You can count clicks through a Promotions
controller that handles redirects to the appropriate landing page, based on the landing_page
field.Upvotes: 1