[pmwiki-users] Pagelists, adjunct data pages & variable sort orders
Crisses
crisses at kinhost.org
Tue Oct 17 11:04:42 CDT 2006
On Oct 17, 2006, at 11:28 AM, Patrick R. Michaud wrote:
> Oh, sorry, I had the second argument to PageTextVar() incorrect --
> the $: should be omitted from the argument. Try the following instead
> (tested on pmwiki.org):
>
> $FmtPV['$Year'] =
> "PageTextVar('Data-'.MakeBaseName(\$pn), 'Year')";
>
> $FmtPV['$Work'] =
> "PageTextVar('Data-'.MakeBaseName(\$pn), 'Work')";
>
> $FmtPV['$WAuthor'] =
> "PageTextVar('Data-'.MakeBaseName(\$pn), 'WAuthor')";
>
> I've also replaced the recursive call to PageVar(...) with
> a direct call to MakeBaseName() -- this should also be an
> improvement.
Thanks!!
Is this method more efficient than the other method you gave? I
currently have custom sorts that look up the data, rather than
pulling the data into the pages as page variables from the get go.
Other method -- I have:
// custom page sorts
function DataCompare($x, $y, $var) {
## get the Data- versions of the pagenames
$datax = 'Data-' . PageVar($x, '$BaseName');
$datay = 'Data-' . PageVar($y, '$BaseName');
## perform the requested comparison
$c = strcmp(PageVar($datax, $var), PageVar($datay, $var));
return $c;
}
$PageListSortCmp['year'] = 'DataCompare($x, $y, "$:Year")';
$PageListSortCmp['work'] = 'DataCompare($x, $y, "$:Work")';
$PageListSortCmp['wauthor'] = 'DataCompare($x, $y, "$:WAuthor")';
And it's working! Much to my relief.
> I don't remember how you're handling categories... but yes, you
> may be able to do that.
I have categories such as Category/Author-AuthorTName -- when linking
to them from pagelists I have to pull the "Author T. Name" from the
page data to build the category link. That T. in there is a real
problem, so the period needs to be stripped. While I'm at it, I
strip all illegal characters from the pagename -- might as well. If
I don't need to do that, I can change to str_replace, though.
$FmtPV['$sWAuthor'] = "preg_replace('/[^A-Za-z0-9 -]/', '',
PageTextVar('Data-'.MakeBaseName(\$pn), 'WAuthor'))";
I might need the : in there if only because a book title with a : in
it would keep the colon in the Category/Title-Book:AReallyLongBook.
Otherwise, I don't really use :'s in Category titles.
So far my custom link markup seems to work just fine -- it strips the
illegal characters, and doesn't seem too slow.
>> I have
>> Markup('{$var}', '>$[phrase]',
>> '/\\{(\\*|!?[-:\\w.\\/\\x80-\\xff]*)(\\$:?\\w+)\\}/e',
>> "htmlspecialchars(PageVar(\$pagename, '$2', '$1'),
>> ENT_NOQUOTES)");
>> in my config.php -- I tried commenting it out and my {$:Vars}
>> broke
>
> Yes. You need the custom {$var} rule here because some of your
> pages' names have colons in them.
>
> Pm
Great, this time I'll comment WHY it's there so I don't forget. You
never think you'll forget something til you forget it. :P Given my
circumstances, I really ought to know better.
One more question:
How would one use a searchbox to search a specific field. I have the
alphabetical links that do $:Work=T* -- if I want the contents of the
searchbox ("Blue") to become $:Work=*Blue* so that one can find all
pages with Blue in the title.... is there a way to transfer q=Blue to
$:Work=*Blue* ??
Crisses
More information about the pmwiki-users
mailing list