Skip to content

Instantly share code, notes, and snippets.

@nbrew
Created October 8, 2010 23:17
Show Gist options
  • Save nbrew/617719 to your computer and use it in GitHub Desktop.
Save nbrew/617719 to your computer and use it in GitHub Desktop.
# Method 1: add an after filter to set the variable, use it in the application layout
PageController.class_eval do
after_filter :set_header_quote, :only => [:show]
private :set_header_quote
def set_header_quote
@header_quote = 'Some header quote'
end
end
# in the layout
<div id="header"><%= @header_quote %></div>
# Method 2: add header_quote as a PagePart, then utilize it in either the application or layout
# run in console to add the part to all pages
Page.all.each {|p| p.parts << PagePart.create(:title => 'header')}
# configure ensure that all future pages created with the backend have the header
# (only when using the pnt_pages plugin or an upcomming version of the gem)
Page.class_eval do
def self.default_page_parts
['body','side_body','header']
end
end
# application (conditional required because not all actions assign a Page)
<% if @page.present? %>
<div id="header"><%= @page['header'] %></div>
<% end %>
# shared/content_page
<div id="body_content">
. . .
<div id="header"><%= @page['header'] %></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment