Skip to content

Commit

Permalink
* Fixed Category::find_all_with_article_counters to include empty ca…
Browse files Browse the repository at this point in the history
…tegories again (closes #377)

 * Fixed category sidebar configuration to actually update the settings properly if neither of the checkboxes are checked (closes #396)


git-svn-id: http://svn.typosphere.org/typo/trunk@645 820eb932-12ee-0310-9ca8-eeb645f39767
  • Loading branch information
scoop committed Sep 11, 2005
1 parent 532105b commit 84bc61b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 2 additions & 4 deletions app/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ class Category < ActiveRecord::Base

def self.find_all_with_article_counters
self.find_by_sql(%{
SELECT categories.id, categories.name, categories.permalink, categories.position, COUNT(article_id) AS article_counter
SELECT categories.id, categories.name, categories.permalink, categories.position, COUNT(articles.id) AS article_counter
FROM #{Category.table_name} categories
LEFT OUTER JOIN #{Category.table_name_prefix}articles_categories#{Category.table_name_suffix} articles_categories
ON articles_categories.category_id = categories.id
LEFT OUTER JOIN #{Article.table_name} articles
ON articles_categories.article_id = articles.id
WHERE
articles.published = 1
ON (articles_categories.article_id = articles.id AND articles.published = 1)
GROUP BY categories.id, categories.name, categories.position, categories.permalink
ORDER BY position
})
Expand Down
6 changes: 4 additions & 2 deletions components/plugins/sidebars/category/configure.rhtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<%= form_tag({},{:id => 'configure_'+@sidebar.id.to_s, :class=>'configblock'}) %>
<input type="checkbox" id="configure_<%= @sidebar.id.to_s %>_count" name="configure[count]" <% if @sidebar.staged_config['count'] %>checked="checked"<% end %>/>
<input type="checkbox" id="configure_<%= @sidebar.id.to_s %>_count" name="configure[count]" <% unless @sidebar.staged_config['count'].blank? %>checked="checked"<% end %>/>
<input name="configure[count]" type="hidden" value="" />
<label for="configure_<%= @sidebar.id.to_s %>_count">Show article count</label><br/>
<input type="checkbox" id="configure_<%= @sidebar.id.to_s %>_empty" name="configure[empty]" <% if @sidebar.staged_config['empty'] %>checked="checked"<% end %>/>
<input type="checkbox" id="configure_<%= @sidebar.id.to_s %>_empty" name="configure[empty]" <% unless @sidebar.staged_config['empty'].blank? %>checked="checked"<% end %>/>
<input name="configure[empty]" type="hidden" value="" />
<label for="configure_<%= @sidebar.id.to_s %>_empty">Show empty categories</label>
<%= end_form_tag %>
Expand Down
4 changes: 2 additions & 2 deletions components/plugins/sidebars/category/content.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<h3>Categories</h3>
<ul id="categories">
<% for category in @categories -%>
<% if @sb_config['empty'] or category.article_counter.to_i>0 %>
<li><%= link_to category.name, :controller => "articles", :action => "category", :id => category.permalink %> <% if @sb_config['count'] %><em>(<%= category.article_counter %>)</em><% end %></li>
<% unless @sb_config['empty'].blank? and category.article_counter.to_i == 0 %>
<li><%= link_to category.name, :controller => "articles", :action => "category", :id => category.permalink %> <% unless @sb_config['count'].blank? %><em>(<%= category.article_counter %>)</em><% end %></li>
<% end %>
<% end -%>
</ul>
Expand Down

0 comments on commit 84bc61b

Please sign in to comment.