front_end widget breadcrumb done

This commit is contained in:
Rueshyna 2013-02-01 17:07:16 +08:00 committed by chris
parent 2a61470f8b
commit bca4478f68
4 changed files with 21 additions and 7 deletions

View File

@ -3,7 +3,7 @@ class FrontController < ApplicationController
layout false layout false
def show_breadcrumb def show_breadcrumb
@ancestors = Page.find(params[:menu_page_id]).ancestors_and_self.map{|m|m.title_translations[locale]}.delete_at(0) rescue [] @ancestors = Page.find(params[:page_id]).ancestors_and_self
@ancestors.delete_at(0) @ancestors.delete_at(0)
end end

View File

@ -1,9 +1,9 @@
<% if not @ancestors.empty? %> <% if not @ancestors.empty? %>
<div class='category_list'> <div class='category_list'>
<ul class='list'> <ul class='list'>
<%= @ancestors.each do |node| %> <% @ancestors.each do |node| %>
<li class='active'> <li class='active'>
<%= link_to node.title, (node.class.to_s.eql?('Page') ? '/' + node.path : node.url) %> <%= link_to node.title, "/#{node.path}" %>
</li> </li>
<% end %> <% end %>
</ul> </ul>

View File

@ -156,9 +156,7 @@ module ParserCommon
res << "<ul class='list'>" res << "<ul class='list'>"
ancestors.each do |node| ancestors.each do |node|
res << "<li class='active'>" res << "<li class='active'>"
# root = "/" res << "<a herf ='/#{node.path} )}>#{node}</a>"
# res << "<a href='#{edit ? root + admin_page_path(child.id) : (child.class.to_s.eql?('Page') ? root + child.path : child.url)}'>#{child.title}</a>"
res << "<a herf ='/' + node.path )}>#{node}</a>"
res << "</li>" res << "</li>"
end end
res << "</ul>" res << "</ul>"
@ -209,6 +207,7 @@ module ParserCommon
'' ''
end end
end end
# sitemap # sitemap
def parse_sitemaps_edit(body = nil, page = nil, edit=nil) def parse_sitemaps_edit(body = nil, page = nil, edit=nil)
sitemap = body.css('sitemap').first sitemap = body.css('sitemap').first

View File

@ -11,6 +11,7 @@ module ParserFrontEnd
parse_images(body, page) parse_images(body, page)
parse_menu(body, page) parse_menu(body, page)
parse_sub_menu(body, page, site) parse_sub_menu(body, page, site)
parse_breadcrumb(body, page, site)
parse_counter(body) parse_counter(body)
i18n.merge!({locale => body.to_html}) i18n.merge!({locale => body.to_html})
end end
@ -92,6 +93,20 @@ module ParserFrontEnd
end end
end end
# page_breadcrumb
def parse_breadcrumb(body, page, site)
page_breadcrumb = body.css('.page_breadcrumb').first
if page_breadcrumb
res = "<div id='#{page_breadcrumb['id']}', class='#{page_breadcrumb['class']}'>"
res << "<div class='dymanic_load' path='#{front_show_site_breadcrumb_path}'></div>"
res << "</div>"
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
page_breadcrumb.swap(fragment)
else
''
end
end
# page_contents # page_contents
def parse_contents(body, page, edit=nil, locale) def parse_contents(body, page, edit=nil, locale)
public_r_tags = [] public_r_tags = []
@ -181,6 +196,6 @@ module ParserFrontEnd
# breadcrumb # breadcrumb
def generate_breadcrumbs(*args) def generate_breadcrumbs(*args)
"<div class='dymanic_load' path='#{front_show_breadcrumb_path({:menu_page_id => args[0], :page_id => args[1]})}'></div>" "<div class='dymanic_load' path='#{front_show_breadcrumb_path(args[1])}'></div>"
end end
end end