Add a new page part to blog posts.

40 views
Skip to first unread message

Peaceand

unread,
Jun 15, 2016, 12:30:56 PM6/15/16
to Refinery CMS
Hello,

I'm using the Refinery blog gem https://github.com/refinery/refinerycms-blog and it works very well, but I'd really like to add another page part to the blog posts.

The intention is that when a post is viewed, a header image can be shown above the post title. I have this working perfectly on the rest of the site using a page part, and I'd like to do the same thing with the blog pages too.

At the moment there's only Body and Teaser showing, there don't seem to be any option to add more.

I tried optimistically adding:
  config.default_parts = [{ title: "Body", slug: "body" },{ title: "Teaser", slug: "teaser" }, { title: "Page Image", slug: "page_image" }]
to /config/initializers/refinery/blog.rb but unsurprisingly it had no effect.

Is it possible?

Thanks,

Patrick

Philip Arndt

unread,
Jun 15, 2016, 5:47:17 PM6/15/16
to refine...@googlegroups.com
Hi Patrick,

The reason is that the blog gem doesn't use page parts.. they only belong to pages! :)

Body and Teaser are fields on the post itself (well, its translations). If you want another field, then you're going to have to add it with a migration.

Alternatively, as it seems like you want to attach images to a blog post you can use the refinerycms-page-images extension at https://github.com/refinery/refinerycms-page-images which has support for the refinerycms-blog extension https://github.com/refinery/refinerycms-page-images#refinerycms-blog-support

Peaceand

unread,
Jun 16, 2016, 10:06:13 AM6/16/16
to Refinery CMS
page-images worked perfectly. I was worried I wouldn't be able to restrict it to only blog pages/posts but setting:
config.enable_for = [{:model=>"Refinery::Blog::Post", :tab=>"Refinery::Blog::Tab"}]
in /config/initializers/refinery/page_images.rb solved that nicely.

Thanks!
Patrick
Reply all
Reply to author
Forward
0 new messages