Wikka : FormattedIncludeAction

HomePage :: Categories :: Index :: Changes :: Comments :: Documentation :: Blog :: Login/Register

Formatted Include

This is a modification of the wikka include action adding css formatting. The idea & some of the code came from a gpl wikini action by Eric Feldstein.

You can use it to completely replace the include.php file in the action directory.

Useage is....

{{include page="HomePage" class="gray_background solid_border small_fonts height10em"}}

The class parameter is optional.

An example of it in use here.

<?php
// wikka include action modified by GmBowen so that included page is formatted according to css code
// Idea & code modifications from Wikini include action by Eric Feldstein released under GPL
if ($class) {
    $array_classes = explode(" ", $class);
    foreach ($array_classes as $c) { $classes = $classes . "include_" . $c . " "; }
    }
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);
        $output = $this->Format($page["body"]);
        if ($classes) echo "<div class=\"", $classes,"\">\n", $output, "</div>\n";
        else echo $output;
    }
} else print "<span class='error'>Circular reference detected</span>";

?> 


the css file in use has to have the following text added to it....
.include_right { float: right; width: 17%; } /* floating box to the right */
.include_left { float: left; width: 17%; } /* floating box to the left*/
.include_solid_border { border: solid; padding: 2px; } /* solid border*/
.include_gray_background { background-color: #DDDDDD; } /* grey background*/
.include_small_fonts { font-size: 0.8em; } /* small fonts */
.include_big_fonts { font-size: 1.2em; } /* large fonts*/
.include_height10em { height: 10em; overflow: scroll; } /* in a scrollable box 10em high */
.include_height15em { height: 15em; overflow: scroll; } /* in a scrollable box 15em high */
.include_height30em { height: 30em; overflow: scroll; } /* in a scrollable box 30em high */
.include_height60em { height: 60em; overflow: scroll; } /* in a scrollable box 60em high */



CategoryUserContributions
Comments (13) 1-10 | 11-20 | all [Hide comments/form]
Wow, DarTar, that's great, what I'm needing. Any way to activate the formatting? Or does this just permit plain text. I tried it out, and had some [[ ]] links, but they just appeared as plain text, formatting didn't work.
-- JasRandal (2005-07-09 15:50:50)
oh sure, everything within double-doublequotes is escaped and parsed as HTML, so the Wikka formatter will just skip it. You have to add HTML tags if you want to format text between "" "".
-- DarTar (2005-07-09 17:33:04)
It shouldn't be too hard to extend the >> and << syntax with a "property" to set the desired width. Something like >>(200px)...>> to set a width of 200 pixels, or <<(20%)...<< to set a width of 20% of the enclosing element. That could be turned into a style attribute which would be more specific than the global style and so would override it.

Before going down that path though, we should discuss what other properties (if any) we would allow to be specified at the wikka syntax level - to avoid making it into a "full HTML equivalent".
-- JavaWoman (2005-07-14 09:21:44)
1-10 | 11-20 | all
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0882 seconds