Пример #1
0
def build_tree(root=None):
    if root:
        ret =  { 'attributes' : { 'id' : str(root.key()) },
                 'data' : { 'title' : root.title,
                            'attributes' : { 'class' : 'link',
                                             'href' : urlresolvers.reverse('admin_microcms_page_change', args=(root.id,))}},
                 }
        children = root.children()
        if children.count() > 0:
            ret['children'] = [build_tree(page) for page in children]
            ret['state'] = 'open'
        return ret
    
    else:
        return [build_tree(page) for page in Page.all().filter("parent_page =", None).order("order")]
Пример #2
0
def menu_below(context, slug, template='cms/menu.html'):
    page = Page.all().filter("slug =", str(slug))[0]
    return menu(context, template, page)
Пример #3
0
def menu(context, template='cms/menu.html', page=None):
    pages = Page.all().filter("parent_page =", page)
    context.update( {'pages' : pages,
                     'template' : template})
    return context