Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

adds blogs to menu items #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/models/spree/blog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def self.to_options
def to_param
self.permalink.gsub(/(^\/+)|(\/+$)/, "")
end


def matches?(_path)
( _path.delete("/").match(permalink))
end

private

def permalink_availablity
Expand Down
5 changes: 5 additions & 0 deletions app/overrides/add_blogs_to_menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deface::Override.new(:virtual_path => "spree/shared/_store_menu",
:name => "spree_essential_blog_main_menu_items",
:insert_after => "#home-link[data-hook]",
:partial => "spree/shared/blog_main_menu_items",
:disabled => false)
5 changes: 5 additions & 0 deletions app/views/spree/shared/_blog_main_menu_items.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% unless @blogs.blank? %>
<% @blogs.each do |blog| %>
<%= content_tag(:li, link_to(blog.name, blog_posts_path(blog)), :class => blog.matches?(request.path) ? "active" : nil) %>
<% end %>
<% end %>