Skip to content
Nicolas Thiry edited this page Mar 10, 2016 · 1 revision

Spina Layouts

Using ancestry

Ancestry is a gem used by Spina allowing you to manipulate your page tree.

For example this allows you to render the current's page children or parents.

Here is the list of all the methods you can use to navigate your tree.

Here is a short demo of how you can use it (I use SLIM instead of ERB or HAML, but you can understand how it works):

- @page.children.each do |child|
  h2 = child.title

This will render the title of the children of the current page.

Here is another example of how you can do a breadcrumb using ancestry:

ol.breadcrumb
  li
    = link_to "Home", root_url
  - @page.ancestors.each do |ancestor|
    li
      = link_to ancestor.menu_title, ancestor.materialized_path
  li.active
    a = @page.menu_title

menu_title is your Navigation Title in your Advanced tab when creating / updating a page.