diff --git a/app/models/product_categories_block.rb b/app/models/product_categories_block.rb index 8ee5dc8..608a5ea 100644 --- a/app/models/product_categories_block.rb +++ b/app/models/product_categories_block.rb @@ -16,8 +16,20 @@ class ProductCategoriesBlock < Block def content(args={}) profile = owner lambda do - categories = @categories || ProductCategory.on_level().order(:name) - render :file => 'blocks/product_categories', :locals => {:profile => profile, :categories => categories} + if @categories.nil? or @categories.length == 0 + categories = ProductCategory.on_level().order(:name) + if @categories and @categories.length == 0 + notice = _('There are no sub-categories for %s') % @category.name + end + else + categories = @categories + end + render :file => 'blocks/product_categories', + :locals => { + :profile => profile, + :categories => categories, + :notice => notice + } end end diff --git a/app/views/blocks/product_categories.html.erb b/app/views/blocks/product_categories.html.erb index a17559c..bbffe02 100644 --- a/app/views/blocks/product_categories.html.erb +++ b/app/views/blocks/product_categories.html.erb @@ -1,12 +1,9 @@ <%= link_to _('Catalog start'), profile.catalog_url, :class=>'catalog-home-link' %> -<% if categories.present? %> -<% elsif @category.present? %> -
<%= _('There are no sub-categories for %s') % @category.name %>
-<% else %> -
<%= _('There are no categories available.') %>
+<% if notice %> +
<%= notice %>
<% end %> -- libgit2 0.21.2