Login

Snippets by 0sn

Snippet List

Hierarchical Flatpage Tag

Two template tags (I keep them in an app called "utils") handy for building menus out of flatpages. I only have two levels of hierarchy, and the frontpage is dynamic, so that's what it does. There is some flexibility, however, in that you can change the regex that defines a "root" page. You can pass it the flatpage object that is normally given to a flatpage template, or you can pass it a string (for any other page). Deliberatley does not create any markup -- flexibility is key, so it adds the list of root urls or child urls as a name in the current context. You get to pick the name. Please visit the [GitHub archive](http://wiki.github.com/0sn/nameremoved/flatpages) where i keep this up to date, there's a better explanation and you can see it in use.

  • tag
  • flatpage
  • hierarchy
Read More
Author: 0sn
  • 1
  • 6

0sn has posted 1 snippet.