[pmwiki-users] [[!topic |link text]]
john.rankin at affinity.co.nz
john.rankin at affinity.co.nz
Wed Apr 29 15:59:26 CDT 2009
> On Wed, Apr 29, 2009 at 4:39 PM, Peter Bowers <pbowers at pobox.com> wrote:
>> On Wed, Apr 29, 2009 at 3:37 AM, John Rankin
>> <john.rankin at affinity.co.nz> wrote:
>>> Is there a reason why pmwiki.org treats this as
>>>
>>> [[topic |link text]]
>>>
>>> (i.e. links to the current group) rather than
>>>
>>> [[$CategoryGroup/topic |link text]]
>
> ...
>
> So I was asking if there was some other way to assign that
> "class=categorylink" while following the [[~Abc]] pattern of using an
> intermediate markup. So [[!CatX]] would no longer go directly to HTML
> but would first go to [[Category/CatX]] and then in a second step
> (using the other link rules) would go to HTML. This would allow all
> the special cases for links to work with categories as well.
>
> I don't know if this clarifies or further muddies the waters...
>
> In few words, this markup in config.php fixes the problem:
>
> Markup('[[!a','<[[|+','/\\[\\[\\!(.*?)\\]\\]/',"[[$CategoryGroup/$1]]");
>
> But it makes non-existent category pages show up with the
> question-mark rather than a typical category link.
>
> -Peter
>
The following will (I think) handle both [[!CatX]] and [[!CatX |text]]:
Markup('[[!', '<[[|', "/\\[\\[!([^|\\]]+)(?:\\s*\\|\\s*(.*?)\\s*)?\\]\\]/e",
"Keep(MakeLink(\$pagename,PSS('$CategoryGroup/$1'),
('$2' ? PSS('$2') : NULL), '',\$GLOBALS['LinkCategoryFmt']),'L')");
The NULL ensures MakeLink uses $1 as the link text, whereas
just putting PSS('$2') will use a zero length string, if $2 is empty.
This would replace the existing ! mrkup rule, as it handles both
cases. I have omitted the "suffix" option, but it could be added.
JR
More information about the pmwiki-users
mailing list