Julian Weimer
Julian Weimer

Reputation: 2625

How do i override the views of the "Images" tab of RefineryCMS' admin area?

Is it somehow possible to override the admin interface of RefineryCMS? Currently i am working on an Online Portfolio based on RefineryCMS + the Portfolio plugin. I basically want to display add image titles and a description, which are sadly missing. Luckily i found instructions of how to hack this sort of functionality into the admin area, but i just don't know how to override those view files in the "vendor/plugins" folder.

Here is the link to the instructions i have found:

http://groups.google.com/group/refinery-cms/browse_thread/thread/929d7462cf075189?pli=1

I know this guide is written for Rails 2 and a former version of RefineryCMS, so things might have changed and probably i have to do it every quite differently.

Thanks in advance.

...I really wonder why they still didn't implement those features into the Plugin.

Upvotes: 0

Views: 1099

Answers (1)

parndt
parndt

Reputation: 1873

The answer to why these are not added into the portfolio extension by default is that the core team behind the portfolio hasn't had a case where they are useful. We rely on patches to improve or add functionality by people who do come across this need. There's an open issue where nobody has really come up with a solution for yet.

As for the implementation itself; to override the file you are wanting to override you must use the task "bundle exec rake refinery:override" (using this post as reference) like so:

bundle exec rake refinery:override view=portfolio/_main_image
bundle exec rake refinery:override view=portfolio/show

This will put the templates in app/views/portfolio/ so that you can modify their contents.

You will also have to change the migration syntax from rails 2 to rails 3 so instead of "script/generate" it's "rails generate".

Because the images extension uses 'attr_accessible' by default for security you will have to use the following code somewhere like config/application.rb:

# Make the title and body fields added to Image accessible for mass assignment
config.to_prepare do
  Image.send :attr_accessible, :title
  Image.send :attr_accessible, :body
end

Please let me know if you want any of this clarified or if I didn't quite answer your questions satisfactorily and I'll elaborate.

EDIT:

If you want to override the backend view for images, just follow the same process but for the backend views:

bundle exec rake refinery:override view=admin/images/_form

Now just add the fields in the same format:

<div class='field'>
  <%= f.label :title %>
  <%= f.text_field :title %>
</div>
<div class='field'>
  <%= f.label :body %>
  <%= f.text_area :body, :class => 'wymeditor widest' %>
</div>

Because you've already added the attr_accessible code it will save fine.

Let me know if this isn't what you wanted.

Phil

Upvotes: 2

Related Questions