![]() |
Search:
|
Page last modified 13:01, 30 Oct 2011 by tehmina.khan
Template:MindTouch > IDF > Functions > GuidePages
GuidePagesTable of contentsNo headers/*** USAGE: GuidePages(root, depth) Create a recursive list of all pages that belong to the guide and categorize them according to their IDF tags. PARAMETERS: root : str|num|map Root page for which to fetch the guide pages. depth : num (optional) Tree depth for pages. ***/ "This template is a function and must be invoked using import()."; var root = $0 ?? $root; var depth = $1 ?? $depth; if(root && root is not map) { let root = wiki.getpage(root); } else if(root is nil) { let root = page; } // build list of all child pages in order of appearance var common_parents = root.parents; var tree = wiki.tree(root.path, depth); var pageids = [ xml.num(id) foreach var id in tree["//@pageid"] ]; var pages = { (p.id): p .. { parents: list.splice(p.parents, 0, #common_parents), parent_id: p.parent.id, topic: #[ t foreach var t in tags where string.startswith(t.value, 'article:topic') ] > 0, tutorial: #[ t foreach var t in tags where string.startswith(t.value, 'article:task-tutorial') ] > 0, troubleshooting: #[ t foreach var t in tags where string.startswith(t.value, 'article:task-troubleshooting') ] > 0, reference: #[ t foreach var t in tags where string.startswith(t.value, 'article:reference') ] > 0, beginner: #[ t foreach var t in tags where string.endswith(t.value, 'beginner') ] > 0, intermediate: #[ t foreach var t in tags where string.endswith(t.value, 'intermediate') ] > 0, advanced: #[ t foreach var t in tags where string.endswith(t.value, 'advanced') ] > 0, feature: #[ t foreach var t in tags where string.endswith(t.value, 'feature') ] > 0, sample: #[ t foreach var t in tags where string.endswith(t.value, 'sample') ] > 0 } foreach var id in pageids, var p = wiki.getpage(id), var tags = p.tags }; var all = [ p foreach var id in pageids, var p = pages[id] ]; let export = { pages: all, all: all, tree: tree, topics: [ p foreach var id in pageids, var p = pages[id], if p.topic ], tutorials: [ p foreach var id in pageids, var p = pages[id], if p.tutorial ], troubleshootings: [ p foreach var id in pageids, var p = pages[id], if p.troubleshooting ], references: [ p foreach var id in pageids, var p = pages[id], if p.reference ] }; |
|
Powered by MindTouch Core |