|
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: Administration
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
);
SDV($DefaultPage, 'Main.HomePage');
$pagename = MakePageName($DefaultPage, $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
);
SDV($DefaultPage, 'Main.HomePage');
$pagename = MakePageName($DefaultPage, $pagename);
$FmtPV['$PageUrl'] = 'PUE(($group==$GLOBALS["DefaultGroup"])
? "$ScriptUrl/$name"
: "$ScriptUrl/$group/$name")';
######################################
NotesIf you change the
from
$pagename = MakePageName('Main.HomePage', $pagename);
to
$pagename = MakePageName(Fix for links to non-existing pagesThis fix requires apache2's mod_rewrite. I have only tested it in conjunction with CleanUrls' URL Rewriting Example 3, but it should be extendible to other cases. In the .htaccess file described by CleanUrls' URL Rewriting Example 3, replace: # Send requests to pmwiki.php, appending the query string part. RewriteRule ^([A-Z0-9\xa0-\xff].*)$ pmwiki.php?n=$1 [QSA,L] with: #Send single name pages to pmwiki.php?n=Main.$1 RewriteRule ^([A-Z0-9\xa0-\xff][^\.\/]*(\?.*)?)$ pmwiki.php?n=Main.$1 [QSA,L] # Send requests to pmwiki.php, appending the query string part. RewriteRule ^([A-Z0-9\xa0-\xff].*)$ pmwiki.php?n=$1 [QSA,L] Note: A 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 Works great! A problem is that when a page is not found in Main (and isn't another group), Main.HomePage is shown instead of the offer to create a new page. How could this be solved? This only happens for the short form without the group. wvengen? 13/02/09 NOTE: This recipe is broken and un-maintanined. After applying this recipe, links to non-existing pages in the Main/ group DO NOT WORK. Instead they open Main/Welcome for editing. I have been unable to find a work-around or support for this issue. TRhodes July 07, 2009
Added the 'Fix for links to non-existing pages' section to work-around the previously described problem. -SMaddox Sep 22, 2009 Thanks for trying, but the fix for links to non-existing pages still isn't working for me. Is it working for anyone else? Jeff Links to non-existant pages work, but if you enter non-existant URL, than it won't give you quick link for the new page. Furthermore, this recipe is conflicting with LimitWikiGroups method 2. If enabled both, config.php will set the edit password as an admin somewhy. Tautrimas November 17, 2009, at 02:55 PM See AlsoContributorsPm
User notes?: If you use, used or reviewed this recipe, you can add your name. The following format is recognized:
* (+) Optional positive comment. Name, date * (-) Optional negative comment. Name, date These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |