|
Cookbook /
SharedPagesSummary: Share selected pages among several wikis on a common server, as in WikiFarms
Status: Stable
Prerequisites: pmwiki-2.1.beta10
Maintainer: Pm
Categories: WikiFarms, CustomPageStore
Version: 2005-12-05
Discussion: Cookbook.SharedPages-Talk Cookbook.SharedPages-Users
DescriptionThe general approach to sharing pages is to create a special shared.d/ directory to hold the shared pages, and then configure the Normally the shared.d/ directory will go in the same directory of the main PmWiki installation, but any directory will work for this. Sharing pages "read only"To have shared pages that cannot be directly modified by any of the wikis, use a configuration such as:
The above can be placed in a wiki's local/config.php file, or it can go into a farm's local/farmconfig.php to cause all fields of the farm to use the shared pages. Then, move any pages that are to be shared from a wiki.d/ directory into the shared.d/ directory. Any pages in the shared directory will then be visible to all of the wikis configured to use that directory. However, when the shared.d/ directory is read-only as in the above, then any (field) wiki that modifies (edits) the shared page will place the page in its local wiki.d/ directory and use the local copy in preference to the shared copy. Sharing writable pagesIf we want a wiki to be able to write into the shared pages, then the configuration is slightly more complex: $LockFile = " We also have to make sure the shared.d/ directory is writable by the webserver -- usually As before, the above lines go into a local/config.php, or into local/farmconfig.php if the pages are to be shared by all fields in a farm. Any pages to be shared should be moved from wiki.d/ into the shared.d/ directory. You can have more than one writable shared directory. Notice that there is still only 1 $LockFile. $LockFile = " Sharing writable groupsTo share groups of pages that can be updated and added to (ie new pages) from both websites, where
Re-define the
<?php
## only alter the directories when a page is posted in this group
if (@$_REQUEST['action']=='edit'
&& preg_grep('/^post/', array_keys($_REQUEST) ) ) {
$LockFile = "$FarmD/shared.d/.flock"; # set a shared lock file
$WikiDir = new PageStore('$FarmD/shared.d/$FullName'); # shared writeable page store
$WikiLibDirs = array( &$WikiDir,
new PageStore('$FarmD/wiki.d/$FullName', 1), # writable page store
new PageStore('$FarmD/wikilib.d/$FullName') ); # default PmWiki pages
}
Sharing local.css files on the farmYou can use the farm's pub/css/ directory to share local.css files by redefining the Currently the pmwiki distribution of skins.php uses
NotesNote that any passwords on shared pages are evaluated in the context of the wiki being accessed; i.e., as if the shared pages were stored locally in the wiki. Comments
There's not really a way to do this yet, sorry. You might try using a custom InterMap link for files in a shared uploads directory. --Pm
## (:if field1:) is true when hostname contains "field1"
$Conditions['field1'] = (strpos($_SERVER['HTTP_HOST'], 'field1') !== false);
## (:if field2:) is true when hostname contains "field2"
$Conditions['field2'] = (strpos($_SERVER['HTTP_HOST'], 'field2') !== false);
Then you can have conditionals like
(:if field1:)
This content is visible only to people accessing field1.mydomain.com.
(:if field2:)
This content is visible only to people accessing field2.mydomain.com
(:if:)
Everybody sees this.
See Also
Contributors
User notes +2: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |