This is a little action I made for including a page in another page, for example, a navigation bar. This is very useful if you want the same thing to appear on many different pages, but you don't want to have to edit each page every time you want to change something.


{{incpage page="PageName"}}

Save the following script as actions/incpage.php

-- Jamie

Hi Jamie. Thank you for the contribution, however it appears that your action duplicates an action that is already in Wikka version and above. You can see the code for the standard Wikka 'include' action on the IncludeAction page. To avoid confusion, my preference is to remove this page. -- JsnX

if (!isset($vars['page'])) {
echo "No page specified.<br><br><strong>Syntax: {{incpage page=\"wikiname\"}}</strong>  (Case insensitive)";
else {
$url = $vars['page'];
$host = $this->config['mysql_host'];
$db = $this->config['mysql_database'];
$user = $this->config['mysql_user'];
$passwd = $this->config['mysql_password'];
$connection = @mysql_connect($host, $user, $passwd);
@mysql_select_db($db, $connection);
$sql = "select body from" . $this->config['table_prefix'] . " pages where tag=\"$url\" and latest=\"Y\"";
$query = mysql_query($sql, $connection);
while ($nav = mysql_fetch_array($query)) {
$body = $nav['body'];
$body = $this->Format($body, "wakka");
echo $body;

I wasn't sure where to put this question, forgive me if I am breaking Wiki-netiquette. I thought perhaps instead of deleting this page, someone could help me with a small upgrade to the IncludeAction. See, I am attempting to use WikkaWiki as a PIM and have been playing with some of the contributions on the GmBowenWikkaAsPIM page. One thing I want to do however is to have a page that lists my current projects which themselves are each Wiki Pages. Each of these Wiki Pages start out with a To Do list at the top. What I want is for the Project list page to have "includes" that pull "x" number of lines from the specified Wiki Page instead of the whole thing as the include Action currently does.

I'm pretty brain dead in this explanation so here is a screenshot that should explain what I mean better. Notice the automatic line numbering.
PimInclude Example

Here's my include.php hack at this point. (Be gentle. I'm not a programmer, nor familiar with PHP). It takes "page", as before, and now also "numlines" which is pretty self explanatory.


if (is_array($vars))
    foreach ($vars as $param => $value)
        if ($param == 'page') {
            $page = strtolower($page);
        if ($param == 'numlines') {

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);
        if (!$numlines) {
            print $this->Format($page["body"]);
        else {
            $newtext = $this->Format($page["body"]);
            $newtext = explode ("\n", $newtext);
            $i = 0;
            while ($i <= $numlines-1) {
                print ($i+1).") ".$newtext[$i]."\n";
} else print "<span class='error'>Circular reference detected</span>";


There are little quirks that I'd like help fixing. Such as that styles get messed up if you have indentations on your to do list items. Also things obviously get a little wierd if one of your To Do list items it a subproject page with an include call to to do list items it contains. I'd like it to be able to handle this though. I think this is one thing that could make Wikka pretty capable of being a hipster GTD solution. ;)

There are 6 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki