[pmwiki-users] Can I make conditional markups look into includes?
Petko Yotov
5ko at 5ko.fr
Tue Jun 6 05:03:26 PDT 2023
As you noted, the page index, and the link index, do not include texts
from included pages.
Moreover, link index targets do not include the #hash of the link, so
this would need to be manually parsed.
Moreover, (:include...:) directives are evaluated after (:if...:)
conditionals, so when the markup engine sees (:if...:), all text
included from other pages may not yet be in the page.
So what you are trying to do is really not obvious. :-)
Is the footer conditional in a GroupFooter page?
Will the footer text inside the conditional change often?
It might be possible to add a custom directive or a post-processing
function.
Petko
--
If you upgrade : https://www.pmwiki.org/Upgrades
On 03/06/2023 20:35, Thomas Hirtenlehner wrote:
> I'm searching for specific keywords in my page to add certain
> messages in the footer.
>
> For this I added several (:if intext keyword:)...
> In the footer.
>
> However, as stated in the documentation, (:if intext... :) does not
> look into text that comes from an include for example.
>
> Is there a way to circumvent this? The best case would be to make it
> look only in the main page, but I'm fine with completely circumventing
> this restriction for certain sites...
>
> 8 May 2023 18:35:58 Thomas Hirtenlehner
> <Thomas.hirtenlehner at tielor.at>:
>
>> OK, I should have kept thinking about it. I can solve this problem
>> with the inclusion of intext:
>>
>> _(:if2 link mypage.test:)_
>>
>> _(:if intext mypage.test#part1:)_
>> _Text 1_
>> _(:ifend:)_
>>
>> _(:if intext mypage.test#part2:)_
>> _Text 2_
>> _(:ifend:)_
>>
>> _(:if2end:)_
>>
>> does the trick
>>
>> Sorry for bothering everyone :/
>>
>> 8 May 2023 16:53:32 Thomas Hirtenlehner
>> <thomas.hirtenlehner at tielor.at>:
>>
>>> 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
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
More information about the pmwiki-users
mailing list