I am currently working on the eCommerce project motociclisti.pl based on Spree – „the world’s most flexible eCommerce platform”, as they advertise 😉
Motivation
I needed some tool to manage static pages – like contact, terms of use, some promo-pages etc. Eventually, I’ve decided to go for spree_essential_cms developed by Spencer Steffen & Citrus. What I was missing there, was the tool to manage menus. So it was time to add some gem to spree community
I have developed spree_essential_menus gem, which smoothly integrates with spree > 1.0.0 and spree_essential_cms > 0.3.0.
Installation
Add the following line to your gemfile:
gem 'spree_essential_menus'
Then run bundle.
Copy the migrations to your app (yeah, I know, I should add it to extension generator for the future):
bundle exec rake railties:install:migrations
and in the end run rake db:migrate. You are ready to play!
Usage
The SpreeEssentialMenus extension adds a subtab Menus to spree_essential tab (usually Static content, depending on you translation). You should first create Menu bars that you need for your shop (usually main menu and footer menu, but can be infinitely many).
Then in every menu bar, you can create as many menu elements as you want to.
You have two options:
- manually type the path (it can be both relative or absolute, but in case of aboulute path remember to start with „http://”)
- select a static page created in spree_essential_cms, that the menu element should point to. In this case, the path will be filled in automatically.
How to rearrange menu elements?
The menu elements can be easily reorganized by drag&drop functionality – just click on green arrows left to the element’s name in the index page of selected menu bar’s elements and drag it where you want to.
How to embedd it in my layout?
When you create Menu bars, you can easily embedd them in your layout by the partial, like below (written in HAML):
%header %nav - @menu_bar = Spree::MenuBar.find_by_name("main_menu") = render :partial => "spree/shared/render_menu", :locals => {:menu_bar => @menu_bar}
So far, 3 different menu presentations are available:
Nested structure
Recently I’ve also added a nested_set structure for menu_elements. So for every menu element you can select a parent (within the same menu_bar), and thus create a nested menu with submenus.
Issues
So far I do not know any – if you find one, please report on GitHub – https://github.com/matfiz/spree_essential_menus
Feel free to pull and contribute I hope it will be usefull!