Homepage: http://ktd.sytes.net
Email: kickthedonkey@gmail.com

Tricks I've learned

Here are some nifty hacks I've done to Wikka:
Working for 1.1.6.2 to 1.1.6.4 (latest)



Find this line in /libs/Wakka.class.php (around line 660):
    $external_link_tail = $this->GetConfigValue("external_link_tail");
    return $url ? "<a class=\"ext\" href=\"$url\">$text</a>$external_link_tail" : $text;


and replace with:
    $url_parts = parse_url($url);
    $base_parts = parse_url($this->config['base_url']);

    if($url_parts['host'] != $base_parts['host'])
    {
        $external_link_tail = $this->GetConfigValue("external_link_tail");
        return $url ? "<a class=\"ext\" href=\"$url\">$text</a>$external_link_tail" : $text;
    }
    else
    {
        return $url ? "<a href=\"$url\">$text</a>" : $text;
    }


Basically, this hack is getting the base host of the url in question, and comparing that against the base host of the Wikka install. If they're different, the link is identified as an external link. Otherwise, its presented as a regular link.


Find these lines in /libs/Wakka.class.php (lines 1048 & 1049 in 1.1.6.6; lines 1200 & 1201 in 1.2):
    if ('' != $url)
    {


and insert this code below it:
    $url_parts = parse_url($url);
    $base_parts = parse_url($this->config['base_url']);
    if($url_parts['host'] != $base_parts['host']) {$class = 'ext';} else {$class = '';}


Back to CategoryUsers
Comments
Comment by NilsLindenberg
2005-01-12 15:14:33
I've added your hack to the list at CodeContributions. Thank you for it. Please add CategoryUsers to your page and keep posting interesting hacks :)
Comment by BaxilDragon
2009-10-30 16:51:04
My wiki is at a different subdomain (ttu.tomorrowlands.org) than my main website (www.tomorrowlands.org). I slightly modified your v1.2 code, and if you insert these five lines instead of the three you list, it will match the top-level domains ("domainname.tld") instead of the entire hostname:

$url_parts = parse_url($url);

$base_parts = parse_url($this->config['base_url']);

preg_match('/[-_A-Za-z0-9]+\.[-_A-Za-z0-9]+$/', $base_parts['host'], $base_parts_tld);

preg_match('/[-_A-Za-z0-9]+\.[-_A-Za-z0-9]+$/', $url_parts['host'], $url_parts_tld);

if($url_parts_tld[0] != $base_parts_tld[0]) {$class = 'ext';} else {$class = '';}
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki