Permalink
Browse files

Fixed Blog Posts portlet

  • Loading branch information...
1 parent 6ed09aa commit 09fda81e0c8602531e1494650680f2ba7efb62a0 @peakpg peakpg committed Jun 1, 2012
@@ -3,7 +3,7 @@ class BlogPostsPortlet < Cms::Portlet
after_initialize :build_permalink_code
def build_permalink_code
- self.render_blog_post_code ||= 'truncate(blog_post.name, 30)'
+ self.render_blog_post_code
end
# Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI.
@@ -26,7 +26,7 @@ def render(_options = {})
elsif @options[:blog_name]
finder = BcmsBlog::Blog.find_by_name(@options[:blog_name]).posts
else
- finder = BlogPost
+ finder = BcmsBlog::BlogPost
end
if @options[:tags].is_a?(Array) && @options[:tags].size > 1
@@ -1,13 +1,13 @@
-<%= f.cms_text_field :name, :label => 'Portlet Name', :instructions => 'Since we may have many Articles portlets, each with different parameters, give each portlet a descriptive name.' %>
+<%= f.cms_text_field :name, :label => 'Portlet Name', :instructions => 'Give each portlet a descriptive name (ideally, what sorts of posts are being found).' %>
-<%= f.cms_drop_down :blog_id, Bcms::Blog.all.map{|b| [b.name, b.id.to_s]}, :include_blank => true, :label => "Show posts from", :instructions => 'Leave blank to include posts from all blogs' %>
+<%= f.cms_drop_down :blog_id, BcmsBlog::Blog.all.map{|b| [b.name, b.id.to_s]}, :include_blank => true, :label => "Show posts from", :instructions => 'Leave blank to include posts from all blogs' %>
<%# f.cms_drop_down :show_posts_as, [['First post as full post, the rest as Summary + Read More link', 'first_full_post_others_summary'], ['Summary + Read More link', 'summary'], ['Full post', 'full_post'], ['Title (links to post)', 'link']] %>
<%= f.cms_drop_down :show_posts_as, [['Title (links to post)', 'link'], ['Post', 'post']] %>
<%= f.cms_check_box :show_full_posts %>
<%= f.cms_drop_down :category_id, categories_for('Blog Post').map{|c| [c.path, c.id]}, :include_blank => true, :label => "Only posts in category" %>
<%= f.cms_tag_list :label => "Only posts with tags", :instructions => 'Separate tags with spaces' %>
<%= f.cms_text_field :exclude_tags, :label => 'Exclude posts with tags' %>
<%= f.cms_text_field :limit, :label => 'Limit' %>
-<%= f.cms_text_area :render_blog_post_code, :label => 'Code to turn blog_post into link text' %>
+<%= f.cms_text_area :render_blog_post_code, :label => 'Code to turn blog_post into link text', :instructions=>"Default: Truncates name to 30 characters" %>
<%= f.cms_template_editor :template %>
@@ -0,0 +1,12 @@
+<% if @portlet.show_posts_as == 'post'%>
+<%= render :partial => '/partials/blog_post', :collection => @blog_posts, :locals => {:show_full_posts => @options[:show_full_posts]} %>
+<% elsif @portlet.show_posts_as == 'link' %>
+ <ul id="blog_posts">
+ <% @blog_posts.each do |blog_post| %>
+ <% text = @portlet.render_blog_post_code.present? ? eval(@portlet.render_blog_post_code) : text = truncate(blog_post.name, :length=>30) %>
+ <li><%= link_to text, _blog_post_path(blog_post) %></li>
+ <% end %>
+ </ul>
+<% else %>- else
+ Unrecognized option '<%= @portlet.show_posts_as %>' for @portlet.show_posts_as
+<% end %>
@@ -1,9 +0,0 @@
-- if @portlet.show_posts_as == 'post'
- = render :partial => '/partials/blog_post', :collection => @blog_posts, :locals => {:show_full_posts => @options[:show_full_posts]}
-- elsif @portlet.show_posts_as == 'link'
- %ul.blog_posts
- - for blog_post in @blog_posts
- - text = @portlet.render_blog_post_code.present? ? eval(@portlet.render_blog_post_code) : text = truncate(blog_post.name, 30)
- %li= link_to text, _blog_post_path(blog_post)
-- else
- Unrecognized option '#{@portlet.show_posts_as}' for @portlet.show_posts_as

0 comments on commit 09fda81

Please sign in to comment.