1
votes

I'm working on a application utilizing Spree, I want to add essentially static pages to my application within the spree framework. For example I want to have a page that uses the layout I already have designed for Spree (including things such as search, user info etc) and lists two different categories of products within spree with links to them. I tried the spree-static-content extension but the current version seems to have a lot of bugs with the 1.3.1 version of spree and since it is 'static' as far as I understand I couldn't add ruby tags etc to the body content.

I'm not really sure how I would do this using deface and as far as I understand adding the pages and adding routes to a different controller would mean I couldn't use the current layout that retrieves information from the Spree controllers. I also tried simply adding a new definition for the page in the spree controller but this also didn't work and meant that I would have to use a static version of the controller files which would lead to problems when Spree was updated.

Does anyone know how to add new page views within the already existing Spree store?

Thanks!

3
About versions of spree and gems- in many cases you can choose version of gem accordingly to your spree version, for example, go to github.com/spree-contrib/spree_static_content/branches/stale and there you have 1.3.0 version. When you declaring gem in your gemfile you just specify proper branch. - Outside_Box

3 Answers

1
votes

There is a spreecommerce extension spree_static_content for managing static pages from admin.

This extension let you:

  • Add and manage static pages such as an 'About' page.
  • Show a static page instead of existing dynamic pages such as the home page, products pages, and taxon pages.

Using the 'Pages' option in the admin tab, you can add static pages to your Spree install. The page content can be pulled directly from the database, be a separate layout file or rendered as a partial.

In the admin tab, use the 'New page' option to create a new static page.

The title, slug, body, and meta fields will replace their respective page elements on load. The title, slug and body element are all required fields.

Body text provided without a layout / partial being specified will be loaded in the spree_application layout after it is pulled from the database.

Layout and Partial Rendering

To render an entire page without the spree_application layout, specify a relative path to the layout file (eg. spree/layouts/layout_file_name). This file will not be prefixed with an underscore as it is a layout, not a partial.

To render a partial, specify the path in the layout file name and check the 'Render layout as partial' option. The path specified in the layout area will not have an underscore, but it will be required in the filename.

Also note the availability of the render_snippet helper which finds a page by its slug and renders the raw page body anywhere in your view.

Options

Use the 'Show in' checkboxes to specify whether to display the page links in the header, footer or sidebar. The position setting alters the order in which they appear.

Finally, toggle the visibility using the 'Visible' checkbox. If it is unchecked, the page will not be available.

0
votes

Its fairly easy to get your demands with Deface overrides. Just take a peek into default layout template spree_application.html.erb and do Deface's replace, insert_, whatever either with in-place code replacement/insertion or generate particular views and models if needed and write code to render them. This way you can fully customize the layout while keeping&using the default Spree's code.

0
votes

One option would be to mount your Spree Engine in a location other than the root.

Rails.application.routes.draw do

  mount Spree::Core::Engine, at: '/shop'


end

You can then setup a root route as your please and add other pages using the standard rails way or use something like the high_voltage gem.