Include other pages
The following action includes another wikipage and takes care not to be trapped in a circular reference, i.e. included pages can include other pages without running into trouble.actions/include.php
<?php
if (!$page) $page = $wikka_vars;
$page = strtolower($page);
if (!$this->config["includes"]) $this->config["includes"][] = strtolower($this->tag);
if (!in_array($page, $this->config["includes"]) && $page != $this->tag) {
if ($this->HasAccess("read", $page)) {
$this->config["includes"][] = $page;
$page = $this->LoadPage($page);
print $this->Format($page["body"]);
}
} else print "<span class='error'>Circular reference detected</span>";
?>
if (!$page) $page = $wikka_vars;
$page = strtolower($page);
if (!$this->config["includes"]) $this->config["includes"][] = strtolower($this->tag);
if (!in_array($page, $this->config["includes"]) && $page != $this->tag) {
if ($this->HasAccess("read", $page)) {
$this->config["includes"][] = $page;
$page = $this->LoadPage($page);
print $this->Format($page["body"]);
}
} else print "<span class='error'>Circular reference detected</span>";
?>
Thanks, Sebastian. Seems this could be useful. Look for it in the next release, 1.1.4.0. And it's live right now. - JsnX
To use: {{include page="PageName"}} or {{include PageName}}
Fix for case sensitive/insensitive locales
I modified the code so it doesn't break on case sensitive database locales. In cases where there really is a circular reference, this code does two DB queries more than the original to find out the correct case of the included page. Since this shouldn't really happen in the normal case, I don't think that it's an issue.<?php
if (!$page) $page = $wikka_vars;
if (!$this->config["includes"]) $this->config["includes"][] = $this->tag;
if ($this->HasAccess("read", $page)) {
$page = $this->LoadPage($page);
if (!in_array($page["tag"], $this->config["includes"]) && $page["tag"] != $this->tag) {
$this->config["includes"][] = $page["tag"];
print $this->Format($page["body"]);
} else print "<span class='error'>Circular reference detected</span>";
}
?>
if (!$page) $page = $wikka_vars;
if (!$this->config["includes"]) $this->config["includes"][] = $this->tag;
if ($this->HasAccess("read", $page)) {
$page = $this->LoadPage($page);
if (!in_array($page["tag"], $this->config["includes"]) && $page["tag"] != $this->tag) {
$this->config["includes"][] = $page["tag"];
print $this->Format($page["body"]);
} else print "<span class='error'>Circular reference detected</span>";
}
?>
--CyneBeald