diff --git a/app/controllers/breadcrumb_widgets_controller.rb b/app/controllers/breadcrumb_widgets_controller.rb
index 549da60..efa87aa 100644
--- a/app/controllers/breadcrumb_widgets_controller.rb
+++ b/app/controllers/breadcrumb_widgets_controller.rb
@@ -4,13 +4,48 @@ class BreadcrumbWidgetsController < ApplicationController
url = params["url"]
crumbs = url.split("/")
data = []
- crumbs.each do |crumb|
+ uid = nil
+ if params[:page].class == String && params[:page].include?("-")
+ uid = params[:page].split("-").last
+ end
+ crumbs.each_with_index do |crumb,i|
if crumb == ""
p = Page.root
data << {"page_name" => p.name.gsub(/
|
/,''), "url" => "/?locale=#{locale.to_s}"}
else
p = Page.where(:page_id => crumb).first
- data << {"page_name" => p.name.gsub(/
|
/,''), "url" => "/#{locale.to_s}" + p.url}
+ page_name = p.name.gsub(/
|
/,'') rescue ""
+ if i == crumbs.count - 1
+ override_page_name = nil
+ if uid.present? && p.module.present?
+ module_app = ModuleApp.find_by_key(p.module) rescue nil
+ registration_module = OrbitApp::Module::Registration.find_by_key(p.module) rescue nil
+ taggable_model = registration_module.taggable_model.constantize rescue nil
+ puts p.module
+ if module_app && registration_module
+ model = taggable_model.where(:uid=>uid).first
+ if model
+ if (model.category.present? rescue false)
+ override_page_name = model.category.title rescue nil
+ end
+ if (model.tags.present? && model.tags.count == 1 rescue false)
+ override_page_name = model.tags.first.name rescue nil
+ end
+ end
+ end
+ else
+ if params[:category].present?
+ override_page_name = Category.find(Array(params[:category]).first).title rescue nil
+ end
+ if params[:tags].present?
+ override_page_name = Tag.find(Array(params['tags']).first).name rescue nil
+ end
+ end
+ if override_page_name.present?
+ page_name = override_page_name
+ end
+ end
+ data << {"page_name" => page_name, "url" => "/#{locale.to_s}" + p.url}
end
end
{