|
Cookbook /
Per-Group and Per-Page Customizations in config.phpSummary: Place your per-group and per-page customizations in config.php rather than in separate PHP scripts.
Version: Still a draft
Prerequisites: PmWiki 2.x
Status: Quo
Maintainer:
Categories: Administration
Questions answered by this recipeHow can I do per-group and per-page local customizations in config.php rather than the normal way using GroupName.php and GroupName.PageName.php. DescriptionYou can do per-group and per-page local customizations in config.php. This can make keeping track of customizations easier because all local configuration happens in one file rather than several files. You probably will want to place the Group- or page-specific customizations
at the end (bottom) of your config.php local configuration file.
If you do it in a farmconfig.php file, the lines should probably
come after " Getting the group and page nameFirst, you need to make sure the page name is resolved and optionally you can set variables to hold the group and/or page name(s). $pagename = ResolvePageName($pagename); $group = PageVar($pagename, '$Group'); $name = PageVar($pagename, '$Name'); Customization for a groupNow you can do customization for a group.
if ($group == 'SpecialGroup') {
## Your customization here
}
Customization for a pageYou can do customization for a page by page name (that is, customize all pages with a certain name that may exist in any group).
if ($name == 'Test') {
## Your customization here
}
You can also do fancier name-matching, of course. Here is an example that affects all pages, in any group, that have names that end in "-Talk":
if (preg_match('/-Talk$/', $name)) {
## Your customization here
}
Customization for a single pageIf you want your customization to affect only one page, it's done with
if ($pagename == 'Main.WikiSandbox') {
## Your customization here
}
CSS CustomizationsIt's probably best to use
if ($group == 'SpecialGroup') {
$HTMLStylesFmt['specialgroupbg'] = "
#wikibody { background-color:#f7f7ff; } ";
}
NotesCommentsSee AlsoContributors |