Revision [1133]

This is an old revision of SmartTitle made by DarTar on 2004-09-07 09:19:18.

 

How to get smarter titles


By default, page titles in Wikka correspond to their WikiName.
Although this is consistent with Wiki philosophy, in some cases having a dumb WikiName as a title is pretty limiting:

Even though the AddSpace option might partially help, here's a quick and dirty way I figured out to produce smarter titles (you can see a working version of this action here).

This action adds to the title the highest-level header available in the page (in this case =====How to get smarter titles===== ). If no such header is found, then the standard WikiName is displayed.

First save the following code as actions/maketitle.php

<?php
$pagecontent = $this->page["body"];
for ($i = 1; $i <= 6; $i++) {
        if (ereg( "(=){".$i."}(.*)(=){".$i."}", $pagecontent, $title)) {
                        $title = str_replace("\"\"", "", $title[2]);
        }
}
if ($title) echo $title;
else echo $this->AddSpaces($this->GetPageTag());
?>


Then make the following change in actions/header.php

old:

       <title><?php echo $this->AddSpaces($this->GetWakkaName())." : ".$this->AddSpaces($this->GetPageTag()); ?></title>


new:

       <title><?php echo $this->AddSpaces($this->GetWakkaName())." : ".$this->Action("maketitle"); ?></title>


Comments and improvements are welcome

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