breadcrumbs for orbit 4.5

This commit is contained in:
Harry Bomrah 2014-06-27 16:58:18 +08:00
parent 901541cf4a
commit be58b377e1
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,21 @@
class BreadcrumbWidgetsController < ApplicationController
def widget
params = OrbitHelper.params
url = params["url"]
crumbs = url.split("/")
data = []
crumbs.each do |crumb|
if crumb == ""
p = Page.root
data << {"page_name" => p.name, "url" => "/#{locale.to_s}" + p.url}
else
p = Page.where(:page_id => crumb).first
data << {"page_name" => p.name, "url" => "/#{locale.to_s}" + p.url}
end
end
{
"crumbs" => data
}
end
end

View File

@ -1,4 +1,10 @@
module BreadcrumbWidget
class Engine < ::Rails::Engine
initializer "breadcrumb_widget" do
OrbitApp.registration "BreadcrumbWidget", :type => "OrbitWidget" do
widget_label "Breadcrumb"
widget_methods ["widget"]
end
end
end
end