How to Remove Title from a Particular Refinery CMS page

In addition to configuring my Refinery CMS site’s homepage to show the contents of my blog posts instead, using the technique I describe at Rendering Blog Posts on Homepage in Refinery CMS, I also didn’t want to display the “Blog” page title in the Homepage body mainly  because I wanted my homepage to show content without spelling it out that my Blog posts were blog posts. I just want content to be displayed on my homepage and don’t want to call it a “Blog”.

It may be safer to handle this on the client CSS side by using the display:none. The reason why it’s probably safer to do this on the client side is because if you upgrade your refinerycms gem version, your code may break and it may be tough to debug the issue.

However, if you are inclined to handle this on the server side, do the following:

The html for the Refinery::Page object is constructed in the Refinery::Pages::ContentPagePresenter class of refinerycms-pages gem. This class has an initializer which will include the title section in the page as long as the page title exists.

Here’s a snippet:

add_default_title_section(page_title) if page_title.present?

It wouldn’t make sense to modify the code that’s located within the gem. Instead, what I did was to copy the contents of the refinerycms-pages-2.x.x/lib/refinery/pages/content_page_presenter.rb file to my Rails application’s lib/ directory so that you can open up and modify the Refinery::Pages::ContentPagePresenter class and keep those changes within your Rails app.

Replace the existing add_default_title_section line with this line below:

add_default_title_section(page_title) if page_title.present? and page_title != "Blog"

This way you can skip creating a title for your Blog page.

However, I also had to modify my config/application.rb and set my autoload_paths to the following to get the above to work:

config.autoload_paths += %W(#{Rails.root}/lib)

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Facebook Twitter Email

Leave a Reply