|
Cookbook /
GetRidOfMainSummary: How to get rid of "Main" group, i.e. all pages in "Main" are accessible and accessed directly in the wiki root
Version: 1.0
Prerequisites:
Status:
Maintainer:
Categories:
Questions answered by this recipeIs there a way to further improve the CleanUrls recipe by getting rid of the "Main" group? DescriptionAdd this to your local/config.php: ## add default group (Main) to page search path
$PagePathFmt = array(
'{$Group}.$1', # page in current group
'{$DefaultGroup}.$1', # page in default group (Main)
'$1.$1', # group home page
'$1.{$DefaultName}', # group home page
);
$pagename = MakePageName('Main.HomePage', $pagename);
## reformat page urls to omit default group (Main)
$EnablePathInfo = 1;
$FmtPV['$PageUrl'] = 'PUE(($group==$GLOBALS["DefaultGroup"])
? (($name==$GLOBALS["DefaultName"]) ? "$ScriptUrl/" : "$ScriptUrl/$name")
: "$ScriptUrl/$group/$name")';
$FmtP["!\\\$ScriptUrl/$DefaultGroup/!"] = '$ScriptUrl/';
If you are using the Index File method in CleanUrls Add this to your local/config.php instead: ######################################
# Eliminate "index.php" & "pmwiki.php" from Urls,
# You may already have the next 2 lines in your config.php if you have previously set up CleanURLs
$EnablePathInfo = 0;
$ScriptUrl = dirname($ScriptUrl)."/";
######################################
# get rid of "Main." from Urls
$PagePathFmt = array(
'{$Group}.$1', # page in current group
'{$DefaultGroup}.$1', # page in default group (Main)
'$1.$1', # group home page
'$1.{$DefaultName}', # group home page
);
$pagename = MakePageName('Main.HomePage', $pagename);
$FmtPV['$PageUrl'] = 'PUE(($group==$GLOBALS["DefaultGroup"])
? "$ScriptUrl/$name"
: "$ScriptUrl/$group/$name")';
######################################
NotesIf you change the Release Notes
CommentsGetRidOfMain and CleanUrls were great! With no experience in PHP or Apache, total time invested: less than two hours, and now my urls are incredibly short and easy to type. I've done it all through the FTP that comes with Windows. Jeff 7/17/07 One problem I've noticed. It still works great, but if someone enters an address for a page that isn't already created, they get a 404 Not Found error message rather than the screen to create a page. It's not a huge deal but I'd like to fix it if possible. Jeff 12/21/07 It's not possible to add 'nc,' to [L] or [QSA,L] in the lines added to the .htaccess file. That way, www.example.com/page is the same as www.example.com/Page, however it disrupts links to static files in the template (css files, images, etc). If the user wants to link using lowercase (like [[pmwiki]]), the two ocurrences of $name in the above codes have to replaced with ucwords($name). Renato 05/11/08 For use with CleanUrls using...
instead of...
...makes the URL a little cleaner. I modified the cookbook code above to reflect this. AndyG 10/29/08 See AlsoContributorsPm |