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 (Ex: "Resume of Chopin, the most eminent Polish composer") and still keep the highest Heading short (=====Resume=====), you can use the following hack and 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');


note: the "<br />" that follows title should be removed too


2) Modify wakka.class file, you'll find it in the /libs/ directory.

Change this fragment of code:
function PageTitle() {
        $title = "";
        $pagecontent = $this->page["body"];
        if (ereg( "(=){3,5}([^=\n]+)(=){3,5}", $pagecontent, $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();
    }


update 2007/01/23 : custom titles should not be mandatory.
Better patch :
function PageTitle() {
        $title = "";
        $pagecontent = $this->page["body"];
        ereg( "(§){3,5}([^=\n]+)(§){3,5}", $pagecontent, $title);             // custom title ?
        if (!$title) ereg( "(=){3,5}([^=\n]+)(=){3,5}", $pagecontent, $title)// smart title ?
        if ($title) {
            $formatting_tags = array("**", "//", "__", "##", "''", "++", "#%", "@@", "\"\"");
            $title = str_replace($formatting_tags, "", $title[2]);
        }
        if ($title) return strip_tags($this->Format($title));               # fix for forced links in heading
        else return $this->GetPageTag();
    }


note: as the custom title should not contain special characters, regexp could be simplified. For example ereg("§§§.*§§§"...)

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. --TomEk

P.S.
Feel free to correct any possible errors. Do some of you guys know how to make a wikka action (more nifty than modifing files manually) out of this? If so feel free to modify this article.

Wikka with UTF-8 support (since version 1.3.2)

§ ASCII code is 0xA7 and because it is bigger than 0x7F, the corresponding UTF-8 code differs. You need to replace in the code above each § whith \xC2§.
Alternatively, you can also choose a free char with an ASCII code below 0x7F (but you will have to change also all your pages title.
In PageTitle() function :
ereg might be replaced with preg_match for deprecated reason and $title = ''; might be changed to $title = array(); --EmeraldIsland
There are 2 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki