Commit 22eb134c865ce554c595dc048cfb8e72fd9bf054
1 parent
f1bd3825
Exists in
master
and in
29 other branches
List root product categories if no sub-categories
ProductCategoriesBlock will be never empty ActionItem896
Showing
2 changed files
with
16 additions
and
7 deletions
Show diff stats
app/models/product_categories_block.rb
... | ... | @@ -16,8 +16,20 @@ class ProductCategoriesBlock < Block |
16 | 16 | def content(args={}) |
17 | 17 | profile = owner |
18 | 18 | lambda do |
19 | - categories = @categories || ProductCategory.on_level().order(:name) | |
20 | - render :file => 'blocks/product_categories', :locals => {:profile => profile, :categories => categories} | |
19 | + if @categories.nil? or @categories.length == 0 | |
20 | + categories = ProductCategory.on_level().order(:name) | |
21 | + if @categories and @categories.length == 0 | |
22 | + notice = _('There are no sub-categories for %s') % @category.name | |
23 | + end | |
24 | + else | |
25 | + categories = @categories | |
26 | + end | |
27 | + render :file => 'blocks/product_categories', | |
28 | + :locals => { | |
29 | + :profile => profile, | |
30 | + :categories => categories, | |
31 | + :notice => notice | |
32 | + } | |
21 | 33 | end |
22 | 34 | end |
23 | 35 | ... | ... |
app/views/blocks/product_categories.html.erb
1 | 1 | <%= link_to _('Catalog start'), profile.catalog_url, :class=>'catalog-home-link' %> |
2 | -<% if categories.present? %> | |
3 | 2 | <ul class="catalog-categories-list"> |
4 | 3 | <% categories.each do |category| %> |
5 | 4 | <%= category_with_sub_list(category) %> |
6 | 5 | <% end %> |
7 | 6 | </ul> |
8 | -<% elsif @category.present? %> | |
9 | - <div class="catalog-categories-notice"><%= _('There are no sub-categories for %s') % @category.name %></div> | |
10 | -<% else %> | |
11 | - <div class="catalog-categories-notice"><%= _('There are no categories available.') %></div> | |
7 | +<% if notice %> | |
8 | + <div class="catalog-categories-notice"><%= notice %></div> | |
12 | 9 | <% end %> | ... | ... |