0
votes

I am building my e-commerce website and have chosen Spree for it. I am in need of having custom admin features other than what spree provides.

For example, I would like to have a new tab in the admin panel. In that panel I need to do some configuration.

Ex: A tab that will allow me to feature a specific product ( ex: cake of the week )

I went through the documentation. But couldn't find any such feature. Is it possible?

I am new to both Spree and Ruby. I come primarily from a PHP/.NET background. Ruby so far has surprised me and is cool.

Updates:

Deface seems to be the way to go for the operation as @gmacdougall suggested. I am still trying out Deface but have so far failed.

For a test, I am attempting to remove the nav tag and add <h1>Hello!</h1> instead.

Deface::Override.new( 
                      :virtual_path => 'admin/shared/_menu',
                      :name => 'custom-admin-tab',
                      :replace => "nav",
                      #:partial => "spree/admin/shared/custom_tabs"
                      :text => '<h1>This is the new NAV</h1>'
                    )

Looking in to the console, I don't see any thing new happening when the following code is entered in app\overrides\custom-admin-tab.rb file.

But the interesting thing is, when I change the :virtual_path to :virtual_path => 'admin/shared/_tabs', Deface shows up and says there were no matches for 'tab'. I tried it with some other files but nothing showed up.

Am I doing some thing wrong?

1
Is my virtual path correct. I also tried spree/admin/shared/_menuZiyan Junaideen

1 Answers

1
votes

You should check out the View Customization Guide for more information on how to add the tab in to the admin area. You can use the Deface gem to add the tab in to the Spree back end. You can provide your own controller and model which provides the functionality you want.

Spree is very customizable, and these sorts of customizations require a bit of work, but are very doable.

EDIT:

Using Spree 2-0-stable this override will override the nav:

Deface::Override.new(
                     :virtual_path => 'spree/layouts/admin',
                     :name => 'custom-admin-tab',
                     :replace => "nav#admin-menu",
                     :text => '<h1>This is the new NAV</h1>'
                    )