Wikka Mod 040

Type: Feature Addition

Credit:

DarTar (main credit for the idea and code)
SmartTitle
DreckFehler (suggestions, comedy and code improvement)
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:


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:
       <title><?php echo $this->GetWakkaName()." : ".$this->GetPageTag(); ?></title>

new:
       <title><?php echo $this->GetWakkaName()." : ".$this->PageTitle(); ?></title>
Comments
Comment by ChristianBarthelemy
2004-11-18 19:50:52
This was already part of the code I got with release 1.1.5.3 but does not seems to work.
Comment by DarTar
2004-11-19 09:04:13
Can you please be more specific? As you see on this server the PageTitle function works fine.
Comment by ChristianBarthelemy
2004-11-19 13:28:15
I just realized what was meant by "Page Title". I thought previously it refered to the big title that is displayed just above the menu line: obviously this one is not changed :-(
So it works as intended.
Comment by DarTar
2004-11-19 17:38:51
Christian, the "big title" - actually a <h2> in the page header - can be modified (for instance, masked) through CSS (see http://www.openformats.org), or even replaced by a Smart Title just by using the PageTitle action (even if I frankly don't see the interest of duplicating a title already displayed on the page).
Comment by AToulon-202-1-15-107.w80-11.abo.wanadoo.fr
2005-01-04 21:38:39
the interest is to increase the density of the keywords in the title, thus increasing the page relevance in search engines results.
Comment by JavaWoman
2005-01-04 23:11:23
"the interest is to increase the density of the keywords in the title"
Actually good page titles are more important for humans than for search engines: the title gets used for a shortcut or bookmark, and also for the reference in a search engine result. Thus *meaningful* titles are what matters most.
SmartTitles mostly does a good job of that even if the page creator didn't think of it.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki