diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb index cf704a5..05d8c9d 100644 --- a/app/controllers/public/search_controller.rb +++ b/app/controllers/public/search_controller.rb @@ -36,6 +36,26 @@ class SearchController < PublicController render :action => @results.keys.first if @results.keys.size == 1 end + # view the summary of one category + def category_index + @results = {} + @order = [] + @names = {} + limit = MULTIPLE_SEARCH_LIMIT + [ + [ :people, _('People'), :recent_people ], + [ :enterprises, _('Enterprises'), :recent_enterprises ], + [ :products, _('Products'), :recent_products ], + [ :events, _('Upcoming events'), :upcoming_events ], + [ :communities, _('Communities'), :recent_communities ], + [ :articles, _('Contents'), :recent_articles ] + ].each do |asset, name, filter| + @order << asset + @results[asset] = @category.send(filter, limit) + raise "No total_entries for: #{asset}" unless @results[asset].respond_to?(:total_entries) + @names[asset] = name + end + end def articles if @search_engine && !@empty_query diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index c1ec497..6f3bd65 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -27,7 +27,7 @@ module SearchHelper def search_page_title(title, category = nil) title = "

" + title - title += '' + category.name + '' if category + title += ' - ' + category.name + '' if category title + "

" end @@ -42,7 +42,7 @@ module SearchHelper [:enterprises, :products].include?(asset) end - def display_results(asset) + def display_results(asset = nil) if map_capable?(asset) and map_search? partial = 'google_maps' klass = 'map' diff --git a/app/views/search/category_index.rhtml b/app/views/search/category_index.rhtml new file mode 100644 index 0000000..b8859a5 --- /dev/null +++ b/app/views/search/category_index.rhtml @@ -0,0 +1,29 @@ +
"> + + <% if @category %> +
<%= image_tag(@category.image.public_filename(:thumb), :id => 'category-image') if @category.image %>
+ <% end %> + + <%= search_page_title(_('Search Results'), @category) %> + <%= render :partial => 'search_form', :locals => { :hint => '' } if @search_engine %> + <%= category_context(@category, params) %> + <%= display_results %> + +
+ <% if @category %> +

<%= _('Sub-categories') %>

+ <% if @category.children.empty? %> + <%= _('No sub-categories') %> + <% else %> + + <% end %> + <% end %> +
+ +
+ +
-- libgit2 0.21.2