JoshL
JoshL

Reputation: 1499

Rails gem for managing content "segments" on a site, such as promotions?

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:

  1. Ability to define default content per block
  2. Ability to schedule content for display
  3. Ability to rotate content
  4. Ability to track all views and eventual conversions
  5. Internationalization

Does anyone know of a gem that does all or parts of the above?

Upvotes: 2

Views: 465

Answers (1)

jefflunt
jefflunt

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:

  1. Set the default value on the html_code field to whatever you want
  2. Scheduling is done via the start_date and end_date fields
  3. Do you mean rotate as in how a jCarousel rotates content visually? You can easily add jCarousel support yourself.
  4. In your view code you can automatically add Google Analytics code to do this, and/or your own code to track how many times a promotion is shown in the rotation, and how many clicks it receives. If you did it a custom way, you would just add a views 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.
  5. See the i18n gem

Upvotes: 1

Related Questions