Created
November 29, 2010 21:37
-
-
Save djones/720672 to your computer and use it in GitHub Desktop.
4 views in Refinery that use a new type of content_page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rendering a custom plugin | |
<% content_for :page_title do %> | |
<%= @destination.title %> | |
<% end %> | |
<% content_for :page_body do %> | |
<section> | |
<h1>Choose from our most popular recommended itineraries below</h1> | |
</section> | |
<%= render @destination.trips %> | |
<% end %> | |
<% content_for :page_side_body do %> | |
<aside> | |
<%= render :partial => "/shared/customize_your_itinerary" %> | |
<%=raw @destination.side_body %> | |
<%= render :partial => "/shared/brochure" %> | |
<%= render :partial => "/shared/have_a_question" %> | |
</aside> | |
<% end %> | |
<%= render :partial => "/shared/content_page" %> | |
rendering a standard page | |
<%= render :partial => "/shared/content_page" %> | |
rendering a home page | |
<% content_for :page_title do %> | |
<%= image_tag('peru.png') %> | |
<% end %> | |
<% content_for :page_body do %> | |
<h1>What Sets Us Apart</h1> | |
<%= raw @page[:what_sets_us_apart] %> | |
<%= render :partial => "/shared/have_a_question" %> | |
<% end %> | |
<% content_for :page_side_body do %> | |
<div class='clearfix'> | |
<%= image_tag('south-america.png') %> | |
<h1>Where Do You Want To Go?</h1> | |
<%= raw @page[:"where_do_you_want_to_go?"] %> | |
</div> | |
<div class='clearfix'> | |
<%= image_tag('brochure-large.png') %> | |
<h1>Vaya Adventures Brochure</h1> | |
<%= raw @page[:vaya_adventures_brochure] %> | |
</div> | |
<h1>What Our Travellers Say</h1> | |
<%= raw @page[:what_our_travellers_say] %> | |
<% end %> | |
<%= render :partial => "/shared/content_page" %> | |
rendering a news index page | |
<% content_for :page_title do %> | |
<%= t('plugins.refinerycms_news.title') %> | |
<% end %> | |
<% content_for :page_body do %> | |
<%= @page[:body] if @news_items.offset == 0 %> | |
<% if @news_items.any? %> | |
<% @news_items.each do |item| %> | |
<article class="news_item_truncated"> | |
<h3><%= link_to item.title, news_item_url(item) %></h3> | |
<p> | |
<small><%= t('.published') %> <%= l(item.publish_date, :format => :long) %></small> | |
</p> | |
<%= truncate item.body, :length => 200, | |
:omission => " ... #{link_to t('.read_more'), news_item_url(item)}", | |
:preserve_html_tags => true %> | |
</article> | |
<% end %> | |
<%= will_paginate(@news_items) %> | |
<% else %> | |
<p><em><%= t('.no_items_yet') %></em></p> | |
<% end %> | |
<% end -%> | |
<%= render :partial => "/shared/content_page" %> | |
content page | |
<section id='body_content'> | |
<h1><%= section(:page_title) %></h1> | |
<section id='page_body'> | |
<%= section(:page_body) %> | |
</section> | |
<section id='page_side_body'> | |
<%= section(:page_side_body) %> | |
</section> | |
</section> | |
content page 2 | |
<section id='body_content'> | |
<h1><%= section(:page_title) %></h1> | |
<% @page.sections do |section| %> | |
<section id='<%= section.name %>'> | |
<%= section(section.name.to_sym) %> | |
</section> | |
<% end %> | |
</section> | |
application helper | |
def section(name) | |
html = yield name | |
if html.blank? and @page[name].present? | |
html = @page[name] | |
end | |
raw(html) | |
end | |
settings.rb | |
Refinery.default_page_parts = [:body, :side_body] | |
when you add a new page part to a page it tells you in a message what to add to your view. |
I like this. I still find page parts a little funky though.
Why so many <section>'s btw?
Yeah should not something be an <article>
Well that's not what I found weird, just the fact that there's sections in the content_page and in the subpages.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like it in principle but I fear this has no / very limited backward compatibility so we have to deprecate first.