Commit 5de43a78e7c09fe95e0e53607d6625f6691e114d

Authored by Gabriela Navarro
Committed by Antonio Terceiro
1 parent 2e81bdc6

Add option to make it possible to show the article's section name.

Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Antonio Terceiro <terceiro@colivre.coop.br>

See merge request !489
plugins/breadcrumbs/lib/breadcrumbs_plugin/content_breadcrumbs_block.rb
... ... @@ -2,8 +2,9 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock &lt; Block
2 2  
3 3 settings_items :show_cms_action, :type => :boolean, :default => true
4 4 settings_items :show_profile, :type => :boolean, :default => true
  5 + settings_items :show_section_name, :type => :boolean, :default => true
5 6  
6   - attr_accessible :show_cms_action, :show_profile
  7 + attr_accessible :show_cms_action, :show_profile, :show_section_name
7 8  
8 9 def self.description
9 10 _('Content Breadcrumbs')
... ... @@ -40,7 +41,18 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock &lt; Block
40 41 proc do
41 42 trail = block.trail(@page, @profile, params)
42 43 if !trail.empty?
43   - trail.map { |t| link_to(t[:name], t[:url], :class => 'item') }.join(content_tag('span', ' > ', :class => 'separator'))
  44 + separator = content_tag('span', ' > ', :class => 'separator')
  45 +
  46 + breadcrumb = trail.map do |t|
  47 + link_to(t[:name], t[:url], :class => 'item')
  48 + end.join(separator)
  49 +
  50 + if block.show_section_name
  51 + section_name = block.show_profile ? trail.second[:name] : trail.first[:name]
  52 + breadcrumb << content_tag('div', section_name, :class => 'section-name')
  53 + end
  54 +
  55 + breadcrumb
44 56 else
45 57 ''
46 58 end
... ...
plugins/breadcrumbs/test/functional/profile_design_controller_test.rb
... ... @@ -41,4 +41,9 @@ class ProfileDesignControllerTest &lt; ActionController::TestCase
41 41 assert !@block.show_cms_action
42 42 end
43 43  
  44 + should 'be able save breadcrumbs block with show_section_name option' do
  45 + get :edit, :id => @block.id, :profile => @profile.identifier
  46 + post :save, :id => @block.id, :profile => @profile.identifier, :block => {:title => 'breadcrumbs', :show_cms_action => false, :show_profile => true, :show_section_name => true }
  47 + assert @block.show_section_name
  48 + end
44 49 end
... ...
plugins/breadcrumbs/views/box_organizer/breadcrumbs_plugin/_content_breadcrumbs_block.html.erb
1 1 <div id='edit-breadcrumbs-block'>
2 2 <%= labelled_form_field check_box(:block, :show_cms_action) + _('Show cms action'), '' %>
3 3 <%= labelled_form_field check_box(:block, :show_profile) + _('Show profile'), '' %>
  4 + <%= labelled_form_field check_box(:block, :show_section_name) + _('Show section name'), '' %>
4 5 </div>
... ...