Adding Titles and Descriptions to images on Portfolio

118 views
Skip to first unread message

jdeely

unread,
Apr 13, 2010, 1:23:25 PM4/13/10
to Refinery CMS
Hi all,

I've been really getting into Refinery and so far it's great!

I wanted to create a title and description for images uploaded to
Refinery using Portfolio
so far I have done the following;

added the columns to the images table
$script/generate migration AddTitleToImages title:string
$script/generate migration AddBodyToImages body:text
$rake db:migrate


modified the field div in this file, * highlighted
vendor/plugins/images/app/views/admin/images/_form.html.erb

<div class='field'>
<%= f.label :uploaded_data, 'Image' %>
<% if params[:action] =~ /(edit)|(update)/ %>
Use current image
<em>or</em>, replace it with this one...
<% end %>
<%= f.file_field :uploaded_data %>
***** <%= f.label :title, 'Title' %>
***** <%= f.text_field :title %>
***** <%= f.label :body, 'Description' %>
***** <%= f.text_area :body, :class => "wymeditor", :rows => 7 %>
</div>


Added these lines to the main image partial in
vendor/plugins/refinerycms-portolio/app/views/portfolio/
_main_image.html.erb

<h2><%= @image.title %></h2>
<p><%= @image.body %><p>

This works in the back-end except for a few visual bugs.
The problem with this is when i click through the thumbnails in the
front-end the titles and descriptions keep stacking on top of the
previous titles and descriptions. The main image changes fine, but
instead of refreshing the title and description, it adds the new one
above the previous titles and descriptions.

How can i stop this repetition so that only one title and description
will show at a time?

thanks in advance,
John

willmg

unread,
Apr 19, 2010, 7:44:08 AM4/19/10
to Refinery CMS
Hi guys,
I'm working with John on this. Does nobody else think this is a useful
feature? What's a portfolio with out the image titles and
descriptions?

I get the feeling that all it needs is a few lines of java to do what
we need. I've tried looking for a solution over the last week to no
avail....

Does anyone have a clue what might stop the extra escriptions and
titles rendering?
--
You received this message because you are subscribed to the Google
Groups "Refinery CMS" group.
To post to this group, send email to refine...@googlegroups.com
To unsubscribe from this group, send email to
refinery-cms...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/refinery-cms?hl=en

http://www.refinerycms.com

jdeely

unread,
Apr 23, 2010, 8:39:07 AM4/23/10
to Refinery CMS
Solved it!

Use the changes on my first post but instead wrap the code in a new
div (we called ours main_image).
in this file;
vendor/plugins/refinerycms-portolio/app/views/portfolio/
_main_image.html.erb

<div id="main_image">
<%= image_fu @image, :portfolio, :id => "portfolio_main_image" unless
@image.nil? %>
<h2><%= @image.title unless @image.title.nil? %></h2>
<p><%= @image.body unless @image.body.nil? %><p>
</div>

Also in

vendor/plugins/refinerycms-portolio/app/views/portfolio/
show_image.html.erb

under the javascript_include_tag make one change identifying the div
***highlighted

var clicked_on = null;
$("ul#portfolio_images li a").click(function(event) {
if (!$(this).hasClass('selected')) {
clicked_on = $(this);
$.get($(this).attr('href'), function(data, textStatus) {
if (textStatus == "success") {
**** $('#main_image').before(data).remove();

This now works without repetition of titles and descriptions and
is a useful feature for portfolio in my opinion

Regards,
Reply all
Reply to author
Forward
0 new messages