Revision [11414]

This is an old revision of CustomPageTitleTag made by TomEk on 2005-10-13 17:00:40.

 

Every HTML page has a TITLE which is used to identify pages in search engines results. For this reasons it is important to have a good (meaningful and descriptive) TITLE for a page.

TITLE tag is the text displayed in the blue bar at the very top of the browser window, above "Back," "Forward," "Refresh," "Print," etc. Although inconspicuous to the user, the title tag is the most important bit of text on a web page as far as the search engines are concerned. Search engines not only assign the words in the title tag more weight, they also typically display the title tag in the search results, making the title tag an important potential call-to-action as well. Thus, the wording of each page's title tag should be thought through carefully.

Page TITLE created with Wikka's SmartTitle

As a matter of fact, Wikka uses the SmartTitle function to produce HTML TITLES from the page content automatically using the highest-level header in the page, if available.
Example: on this page =====The title of a wiki-page===== is the highest header and therefore used as the title.

Custom Page TITLE

But what if you want a TITLE for a page to be different than the highest-level header used in the page text?
Example:
You want to create a page containing a resume. The highest header on your page is =====Resume=====, which would normally also become the TITLE for the page.
However, if you want the page to have a different, more descriptive TITLE, for example: "Resume of Chopin, the most eminent Polish composer", you will have to use the following hack (modify two Wikka files).

Here's how:

1) Modify formatters/wakka.php file to make sure special TITLE setting tags are not printed:
Change this fragment of code:
 // we're cutting the last <br />
$text = preg_replace("/<br \/>$/","", $text);

echo ($text);
wakka2callback('closetags'); 

with this one:
 $text = preg_replace("/§§§.*?§§§/","", $text);  //for cutting out the §§§my title§§§ tag from page content

// we're cutting the last <br />
$text = preg_replace("/<br \/>$/","", $text);

echo ($text);
wakka2callback('closetags'); 


2) Modify wikka.php file, you'll find it in the main directory.

Change this fragment of code:
 function PageTitle() {
		$title = "";
		$pagecontent = $this->page["body"];
		// if (ereg( "(=){3,5}([^=\n]+)(=){3,5}", $pagecontent, $title)) {  //DISABLE SmartTitle cration from highest header 
		if (ereg( "(§){3,5}([^=\n]+)(§){3,5}", $pagecontent, $title)) {   //using §§§My Custom Title§§§ to specify custom TITLE 
			$formatting_tags = array("**", "//", "__", "##", "''", "++", "#%", "@@", "\"\"");
			$title = str_replace($formatting_tags, "", $title[2]);
		}
		if ($title) return $title;
		else return $this->GetPageTag();
	} 

with this one:
 function PageTitle() {
		$title = "";
		$pagecontent = $this->page["body"];
		// if (ereg( "(=){3,5}([^=\n]+)(=){3,5}", $pagecontent, $title)) {  //DISABLE SmartTitle cration from highest header 
		if (ereg( "(§){3,5}([^=\n]+)(§){3,5}", $pagecontent, $title)) {   //using §§§My Custom Title§§§ to specify custom TITLE 
			$formatting_tags = array("**", "//", "__", "##", "''", "++", "#%", "@@", "\"\"");
			$title = str_replace($formatting_tags, "", $title[2]);
		}
		if ($title) return $title;
		else return $this->GetPageTag();
	} 


That's it. Done!

USAGE:
Now if You want to specify a custom TITLE for a page you're editing, you're free to do so. Just use §§§My Custom Tile§§§ to specify your specific TITLE for the page. This way the TITLE of the page doesn't have to be same as the highest Heading on the page.
There are 2 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki