Skip to content

Instantly share code, notes, and snippets.

@ojii
Created May 2, 2014 08:04
Show Gist options
  • Save ojii/8dcc89bb1118fb8b753b to your computer and use it in GitHub Desktop.
Save ojii/8dcc89bb1118fb8b753b to your computer and use it in GitHub Desktop.
last page on path
def last_page_on_path(path):
"""
Given a path (eg /a/b/c/d/e/), find the "last" page on that path.
If we have a CMS tree of:
|-a
| |-b
| | |-c
But no pages after c, returns c.
"""
@mkoistinen
Copy link

What is the parameter 'path' here, exactly? A string?

Also, do you need the last page proper, as in CMSPage, or the last node? So, if, in the path /a/b/c/d/e/, I have an apphook on d, and this app has a DetailView with slug 'e', do you want this to return 'd' or 'e'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment