Wiki source for Mod040fSmartPageTitles


Show raw source

==== Wikka Mod 040 ====
Type: Feature Addition
----
===Credit:===
**DarTar** **(main credit for the idea and code)**
SmartTitle
**DreckFehler** (suggestions, comedy and code improvement)
**[[JsnX | Jason Tourtelotte]]** (refinement and implementation)
----

====Smart Page Titles====

===Description===

Before this mod, page titles in Wikka corresponded to their WikiName.
Although this is consistent with Wiki philosophy, in some cases having a dumb WikiName as a title is pretty limiting:
~-[[WikiName]]s make **""VeryLongTitlesQuiteDifficultToUnderstand""**;
~-They are not an optimal solution for visibility in search engines;
~-They cannot contain accents or other special characters;


After this mod, page titles correspond to the first header found in the page. If no header is found, then the page's WikiName is displayed.

===Code===

Add this code to /wikka.php:
%%
function PageTitle() {
$title = "";
$pagecontent = $this->page["body"];
if (ereg( "(=){3,5}([^=]+)(=){3,5}", $pagecontent, $title)) {
$formatting_tags = array("**", "//", "__", "##", "''", "++", "#%", "@@", "\"\"");
$title = str_replace($formatting_tags, "", $title[2]);
}
if ($title) return $title;
else return $this->GetPageTag();
}
%%

Then make the following change in ##/actions/header.php##

old:
%%(php) <title><?php echo $this->GetWakkaName()." : ".$this->GetPageTag(); ?></title>%%
new:
%%(php) <title><?php echo $this->GetWakkaName()." : ".$this->PageTitle(); ?></title>%%
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki