Translations of this page?:

Showing the start page of a namespace when a page does not exist

Idea

To go to a start page in a namespace, the id must be namespace:start. There are several solutions around (here or here) to redirect id=namespace: to the corresponding start page. However, I wanted a solution that even id=namespace (without trailing colon) is redirected.

This redirection, of course, must only take place when the page (namespace) isn't there.

Hack

In doku.php, find the line that reads

 //send 404 for missing pages if configured

(should be around line 59). Before this line, add the folloging lines:

   // if a page does not exist, but a namespace with that name and a default page, go to that page
   if(!$INFO['exists'] && @file_exists(realpath(wikiFN($ID . ':' . $conf['start'], null)))) {
       $ID .=  ':' . $conf['start'];
       $INFO = pageinfo();
   }

What it does

The lines check if the current pages is non-existant, and if the configured start page for the namespace exists. If this is the case, the ID is set to this start page, and the pageinfo is regenerated.

Drawback

When a name space exists, it's not able to create a page with the same name as the name space. (Shouldn't be a problem ;-))

 
wiki/tips/namespacestartpage.txt · Last modified: 2008/02/26 17:16 by 207.63.248.238
 
Imprint Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsTranslate