[pmwiki-users] Foldered wiki.d Page Store for more than 100k pages in a group
Petko Yotov
5ko at 5ko.fr
Thu Aug 6 15:42:48 CDT 2015
On 2015-08-06 19:10, ABClf wrote:
> $WikiDir = new PageStore('wiki.d/{$Group}/{$Name1}/{$FullName}');
>
> My biggest group is for Quotes ; pages are named numerically, from 1,
> 2, 3, etc., to 99500 (still growing) ;
> I would like the coming next pages named 100000 and up to be saved in
> folder /11, /12, etc., rather than in folder /1 ;
You can create a custom PageVariable and use it when defining the
PageStore class.
function DirPrefix($group, $name) {
if ($group == 'Quotes' && preg_match('/^(\\d+)\\d{4}$/', $name, $m))
return $m[1]; # >= 100000
return function_exists("utf8string")
? utf8string($name, 0, 1)
: $name{0};
}
$FmtPV['$DirPrefix'] = 'DirPrefix($group, $name)';
$WikiDir = new PageStore('wiki.d/{$Group}/{$DirPrefix}/{$FullName}');
This will keep the current directories with the first letter, in all
groups. For pages in the Quotes group, for names longer than 4 digits,
it will remove the last 4 digits, so
Quotes.99999 will go into wiki.d/Quotes/9/
Quotes.100001 will go into wiki.d/Quotes/10/ (not /11)
Quotes.999999 will go into wiki.d/Quotes/99/
Quotes.2222222 will go into wiki.d/Quotes/222/
Quotes.98765432 will go into wiki.d/Quotes/9876/
This will also take care of the same problem when you go above 999999.
:-)
Petko
--
Change log : http://www.pmwiki.org/wiki/PmWiki/ChangeLog
Release notes : http://www.pmwiki.org/wiki/PmWiki/ReleaseNotes
If you upgrade : http://www.pmwiki.org/wiki/PmWiki/Upgrades
If this message helped you and saved you time, feel free to make
a small contribution: http://5ko.fr/donate-ml (mailing list).
More information about the pmwiki-users
mailing list