Skip to content

Commit

Permalink
Made changing page parts documentation consistent with master.
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Aug 8, 2012
1 parent 8eb211b commit 5866ccc
Showing 1 changed file with 39 additions and 25 deletions.
64 changes: 39 additions & 25 deletions doc/guides/2 - Refinery Basics/1 - Changing Page Parts.textile
@@ -1,6 +1,8 @@
h2. Changing Page Parts

Refinery sets up two default page parts +Body+ and +Side Body+. Sometimes this is not suitable for your project. This guide will show you how to:
Refinery sets up two default page parts +Body+ and +Side Body+.
Sometimes this is not suitable for your project.
This guide will show you how to:

* Change the default page parts to be something else
* Add a new page part to a single page
Expand All @@ -9,52 +11,64 @@ endprologue.

h3. Changing default Page Parts

Refinery by default provides you with +Body+ and +Side Body+ page parts because most pages have a two column style layout. If your layout has three content areas or one, you're going to want to update this setting to reflect that.
By default, Refinery provides you with +Body+ and +Side Body+ page parts since
most pages have a two column-style layout. If your layout has three content
areas or one, you're going to want to update this setting to reflect that.

Within @config/initializers/refinery/pages.rb@ you will see various default settings are commented out including the following:
Within @config/initializers/refinery/pages.rb@ you will see various default
settings are commented out, including the following:

<ruby>
# Configure global page default parts
# config.default_parts = ["Body", "Side Body"]
# Configure global page default parts
# config.default_parts = ["Body", "Side Body"]
</ruby>

Edit this code to have the names of the default page parts you want, click +Save+ and you're done.
Edit this code to have the names of the default page parts you want, click +Save+
and you're done.

Here's a sample of a site that would have three content areas on most of its pages.
Here's a sample of a site that would have three content areas on most of its
pages.

<ruby>
# Configure global page default parts
config.default_parts = ["Left Body", "Middle Body", "Right Body"]
# Configure global page default parts
config.default_parts = ["Left Body", "Middle Body", "Right Body"]
</ruby>

h3. Changing Page Parts for a single page

Often we find our home pages have three or more page parts but the rest of the site only needs two. In this situation you just want to have the default page parts set to Body and Side Body and your home page setup to have an extra one.
Often we find our home pages have three or more page parts but the rest of the
site only needs two. In this situation you just want to have the default page
parts set to Body and Side Body and your home page setup to have an extra one.

Refinery supports the ability for the user to add new Page Parts on the fly when editing a page.
Refinery supports the ability for the user to add new Page Parts on the fly when
editing a page.

To add a new Page Part just to the home page, first we need to go into @config/initializers/refinery/pages.rb@. Find and change this line:
To add a new Page Part just to the home page, refer back to
@config/initializers/refinery/pages.rb@. Inside, you should see the following:

<ruby>
# config.new_page_parts = false
# config.new_page_parts = false
</ruby>

to a true value:
Uncomment this and change the value to true, save, and restart your server.

<ruby>
config.new_page_parts = true
</ruby>
Now go to your "Pages" tab in Refinery and edit your home page. You'll notice a
plus and minus button at the top right of the visual editor. Click on the plus
icon and add a new page part titled "Middle Body" and click save. A new visual
editor will appear in a tab called "Middle Body" ready to use just for this
page. Inserting content there will show up on any page that uses the
@content_page@ partial (by default, all of them).

Now go to your "Pages" tab in Refinery and edit your home page. You'll notice a plus and minus button at the top right of the visual editor. Click on the plus icon and add a new page part titled "Middle Body" and click save. A new visual editor will appear in a tab called "Middle Body" ready to use just for this page.
WARNING. If you've modified your @app/views/refinery/pages/home.html.erb@ file,
you will not see your new page part until you set that page part to display in
the view.

NOTE: Your "middle body" content won't show on the front end yet. You need to output the content of that page part in the view.

Now in your +app/views/refinery/pages/home.html.erb+ view you'll be able to put:
If you have modified your @home.html.erb@ file, you can use the following
snippet to output the new part's content in your page:

<erb>
<%= raw @page.content_for(:middle_body) %>
<%= raw @page.content_for(:middle_body) %>
</erb>

to output this new content area in the view.

NOTE: If you don't have a +app/views/refinery/pages/home.html.erb+ view already, run +rake refinery:override view=refinery/pages/home+ to copy it into your app.
NOTE: If you don't have a +app/views/refinery/pages/home.html.erb+ view already,
run +rake refinery:override view=pages/home+ to copy it into your app.

0 comments on commit 5866ccc

Please sign in to comment.