[pmwiki-users] Pagelist problems (pretty advanced)
Crisses
crisses at kinhost.org
Mon Oct 16 13:31:57 CDT 2006
On Oct 16, 2006, at 1:19 PM, Patrick R. Michaud wrote:
> On Sat, Oct 14, 2006 at 11:44:32AM -0400, Crisses wrote:
>> Another problem --
>> When a field has a period in it, and I need to make the data
>> part of a
>> pagename... (this MAY be related to the problem I originally
>> posted).
>> [@
>> [[#othercatlist]]
>> (:if expr ( ! equal "{Data-{=$BaseName}$:Year}"
>> "{Data-{<$BaseName}$:Year}" ) || ( ! equal "{Data-{=$BaseName}
>> $:Work}"
>> "{Data-{<$BaseName}$:Work}" ) || ( ! equal "{Data-{=$BaseName}
>> $:WAuthor}"
>> "{Data-{<$BaseName}$:WAuthor}" ) :)
>> * [[ Category/Title-{Data-{=$BaseName}$:Work} |
>> {Data-{=$BaseName}$:Work} ]] -
>> [[Category/Author-{Data-{=$BaseName}$:WAuthor} |
>> {Data-{=$BaseName}$:WAuthor} ]] - [[
>> Category/Year-{Data-{=$BaseName}$:Year} | {Data-{=$BaseName}
>> $:Year} ]]
>> (:ifend:)
>> [[#othercatlistend]]
>> @]
>> Long story short, the WAuthor field sometimes has a period (or
>> two) in
>> it. This obviously won't work to create the Category/Author-
>> Name link.
>> Category/Author-{Data-{=$BaseName}$:WAuthor}
>> For example: if $:WAuthor contains a Jr. in the name, an
>> initial like C.S.
>> Lewis, etc.
>> I had to strip .'s out when creating category links when I had
>> the pages
>> written -- is there any way to process the variables and strip
>> out the
>> periods?
>
> There's not a built-in way to do this, no. It may require a custom
> page variable.
I created a custom markup for the categories. A page variable may
have been easier. I was desperate for something that worked, so I
hacked a new markup [[?PageName | Name of Link]] to strip out the
periods (and any other nasty not-page-name-friendly characters):
// The following markup fixes a problem when retrieving data with
periods
// to create category page markup.
Markup('[[?','<[[!','/\\[\\[\\?([^\|]*)\|?(.*?)\\]\\]/e', "Keep
(MakeLink(\$pagename,PSS(helpXES('$CategoryGroup/$1')),PSS('$2'),'',\
$GLOBALS['LinkCategoryFmt']),'L')");
function helpXES($param) {
$param = preg_replace('/[^A-Za-z0-9 -]/', '', $param);
return $param;
}
and added that to config.php.
I may have introduced other bugs to the program, so I'm more than
willing to hear alternatives :)
Crisses
More information about the pmwiki-users
mailing list