[pmwiki-users] conditional markup by link to anchor

Thomas Hirtenlehner thomas.hirtenlehner at tielor.at
Mon May 8 07:52:39 PDT 2023


Hi everybody!

I added the (:if link ... :) markup to my config.php:

/# add (:if link 'Group.Pagename':) conditional
$Conditions['link'] = 'IsTarget( $pagename, $condparm )';
function IsTarget( $pn, $arg ) {
         $arg = ParseArgs($arg);
         $pn2 = MakePageName($pn, $arg[''][0]);
         $page = RetrieveAuthPage($pn, 'read', true);
         if (in_array($pn2, (explode(',',@$page['targets'])))) return true;
}

/It works great for determining if there is a link to SOMEWHERE on the 
given page.

However: I need to discriminate if the link points to a certain anchor, 
and if so which one.

At the moment the link /[[mypage.test]] /and /[[mypage.test#part3]]/all 
lead to the same result.

I'm searching for a behavior, where /(:if link mypage.test:)/ is true 
for any link to mypage.test, while /(:if link mypage.test#part3:)/ is 
only true if that specific anchor is addressed somewhere on the page.

Does anyone know of a way to extend the markup given to accomplish that?

thanks a lot in advance!
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20230508/18dce09a/attachment.html>


More information about the pmwiki-users mailing list