Commit 358bd132a230a36d346233edb832065fff79de4c
1 parent
71494e1c
Exists in
master
and in
29 other branches
[pluginize-solr] Moving category index back
Showing
3 changed files
with
51 additions
and
2 deletions
Show diff stats
app/controllers/public/search_controller.rb
... | ... | @@ -36,6 +36,26 @@ class SearchController < PublicController |
36 | 36 | render :action => @results.keys.first if @results.keys.size == 1 |
37 | 37 | end |
38 | 38 | |
39 | + # view the summary of one category | |
40 | + def category_index | |
41 | + @results = {} | |
42 | + @order = [] | |
43 | + @names = {} | |
44 | + limit = MULTIPLE_SEARCH_LIMIT | |
45 | + [ | |
46 | + [ :people, _('People'), :recent_people ], | |
47 | + [ :enterprises, _('Enterprises'), :recent_enterprises ], | |
48 | + [ :products, _('Products'), :recent_products ], | |
49 | + [ :events, _('Upcoming events'), :upcoming_events ], | |
50 | + [ :communities, _('Communities'), :recent_communities ], | |
51 | + [ :articles, _('Contents'), :recent_articles ] | |
52 | + ].each do |asset, name, filter| | |
53 | + @order << asset | |
54 | + @results[asset] = @category.send(filter, limit) | |
55 | + raise "No total_entries for: #{asset}" unless @results[asset].respond_to?(:total_entries) | |
56 | + @names[asset] = name | |
57 | + end | |
58 | + end | |
39 | 59 | |
40 | 60 | def articles |
41 | 61 | if @search_engine && !@empty_query | ... | ... |
app/helpers/search_helper.rb
... | ... | @@ -27,7 +27,7 @@ module SearchHelper |
27 | 27 | |
28 | 28 | def search_page_title(title, category = nil) |
29 | 29 | title = "<h1>" + title |
30 | - title += '<small>' + category.name + '</small>' if category | |
30 | + title += ' - <small>' + category.name + '</small>' if category | |
31 | 31 | title + "</h1>" |
32 | 32 | end |
33 | 33 | |
... | ... | @@ -42,7 +42,7 @@ module SearchHelper |
42 | 42 | [:enterprises, :products].include?(asset) |
43 | 43 | end |
44 | 44 | |
45 | - def display_results(asset) | |
45 | + def display_results(asset = nil) | |
46 | 46 | if map_capable?(asset) and map_search? |
47 | 47 | partial = 'google_maps' |
48 | 48 | klass = 'map' | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
1 | +<div id="search-page" class="<%= "view-category" if @category %>"> | |
2 | + | |
3 | + <% if @category %> | |
4 | + <div id="category-image"><%= image_tag(@category.image.public_filename(:thumb), :id => 'category-image') if @category.image %></div> | |
5 | + <% end %> | |
6 | + | |
7 | + <%= search_page_title(_('Search Results'), @category) %> | |
8 | + <%= render :partial => 'search_form', :locals => { :hint => '' } if @search_engine %> | |
9 | + <%= category_context(@category, params) %> | |
10 | + <%= display_results %> | |
11 | + | |
12 | + <div id="category-childs"> | |
13 | + <% if @category %> | |
14 | + <h2> <%= _('Sub-categories') %> </h2> | |
15 | + <% if @category.children.empty? %> | |
16 | + <strong id="cat-no-child"><%= _('No sub-categories') %></strong> | |
17 | + <% else %> | |
18 | + <ul> | |
19 | + <% @category.children.each do |c| %> | |
20 | + <li> <%= link_to_category c, false %> </li> | |
21 | + <% end %> | |
22 | + </ul> | |
23 | + <% end %> | |
24 | + <% end %> | |
25 | + </div> | |
26 | + | |
27 | +</div> | |
28 | + | |
29 | +<div style="clear: both"></div> | ... | ... |