Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Locomotive editor strange behavior with page hierarchy when pushing #520

Closed
jloosfelt opened this Issue · 4 comments

3 participants

@jloosfelt
Collaborator

I have a real issue with an editor site i'm currently working on.
I have main sections and sub-sections, and some other pages.

After reading around I understood that to create a page hierarchy, i'm supposed to declare it this way in my site.yml :

- "section1":
    title: Section 1
    published: true
- "section1/page1":
    title: Page 1
    published: true

And the liquid files are supposed to respect the same organisation :
section1.liquid
section1/page1.liquid

It seems to work. So I used this method with all my pages and when I push my site, the pages are all messed up.

Here is my site.yml : https://gist.github.com/3783112
And here's the pages hierarchy after pushing my site for the first time : https://gist.github.com/3783138

Note that some pages are even at the root level just like index...

Got any idea ?

@did
Owner

solved but I don't remember how.

@did did closed this
@jloosfelt
Collaborator

Sorry did, it was not solved. In the end I had to reorganize all the pages using the backoffice.

@widescape

I also stumbled into this issue. I solved it by changing the method pages_with_layouts_first in lib/locomotive_editor/models/site.rb to:

def pages_with_layouts_first
  self.pages.find_all.map do |page|
    if page.is_layout?
      page
    else
      [all_parents_and_layouts_of(page), page]
    end
  end.flatten.uniq
end

def all_parents_and_layouts_of(page, stack=nil)
  stack ||= []
  stack << page
  list = []
  if page.parent and page != page.parent and !stack.include?(page.parent)
    list += all_parents_and_layouts_of(page.parent, stack)
    list << page.parent
  end
  self.pages.find_all { |p| p.fullpath == page.layout_path }.each do |layout|
    unless stack.include?(layout)
      list += all_parents_and_layouts_of(layout, stack)
    end
    list << layout
  end
  list
end

This will return a nice hierarchy with all dependencies like parents and layouts created before a page is created.

@jloosfelt
Collaborator

Thanks @widescape !
Just for information, the problem went away with a newer version of the editor, I did not find time to test your code. Maybe did used it ?
I also noticed that in the site.yml, I had one more indent than necessary under the - page:

- "section1":
      title: Section 1
      published: true

was supposed to be

- "section1":
    title: Section 1
    published: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.