summaryrefslogtreecommitdiff
path: root/inc/pageutils.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-07-01 11:41:22 +0200
committerAndreas Gohr <andi@splitbrain.org>2012-07-01 14:35:51 +0200
commite66d3e6dfa7ba6f0cf55b58f0b00b66b52c98321 (patch)
tree9904e4a6e8c6d7c9017626e5195e3291388101b3 /inc/pageutils.php
parent65ee48a57f42826189844ad1039c37a8a675dbab (diff)
downloadrpg-e66d3e6dfa7ba6f0cf55b58f0b00b66b52c98321.tar.gz
rpg-e66d3e6dfa7ba6f0cf55b58f0b00b66b52c98321.tar.bz2
Improved sidebar inclusion
Template authors now can use tpl_sidebar() to include the sidebar. Sidebars can be defined in subnamespaces as well
Diffstat (limited to 'inc/pageutils.php')
-rw-r--r--inc/pageutils.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/inc/pageutils.php b/inc/pageutils.php
index c94d14624..f525c44d0 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -622,3 +622,27 @@ function utf8_decodeFN($file){
return urldecode($file);
}
+/**
+ * Find a page in the current namespace (determined from $ID) or any
+ * higher namespace
+ *
+ * Used for sidebars, but can be used other stuff as well
+ *
+ * @todo add event hook
+ * @param string $page the pagename you're looking for
+ * @return string|false the full page id of the found page, false if any
+ */
+function page_findnearest($page){
+ global $ID;
+
+ $ns = $ID;
+ do {
+ $ns = getNS($ns);
+ $pageid = ltrim("$ns:$page",':');
+ if(page_exists($pageid)){
+ return $pageid;
+ }
+ } while($ns);
+
+ return false;
+}