00707: Add conditional markup to detect if text is included
Description: ConditionalMarkup provides a powerful way to provide some control over the content of a page.
This proposal is to extend the conditional markup to detect if the page, or part of a page, in which the IF occurs to be able to detect when the text is included, or not.
This will provide a level of control on what is displayed on the original page, and what is displayed on the including page, over and above what can be done using (:include:)
.
eg
(:if included:)
| - |
the current text is included (via (:include:), not via a template) in the page displayed. |
this could be extended to detect where the include is, eg | ||
(:if included sidebar:)
| - |
the current text is included (via (:include:), not via a template) in the sidebar of the page displayed. |
(:if included groupheader:)
| - |
the current text is included (via (:include:), not via a template) in the group header page displayed. |
(:if included groupfooter:)
| - |
the current text is included (via (:include:), not via a template) in the page group footer displayed. |
(:if included body:)
| - |
the current text is included (via (:include:), not via a template) in the body of the page displayed. This is the default. |
negated form of the condition should also work | ||
(:if ! included:)
| - |
the current text is not included (via (:include:), not via a template) in the page displayed. |
combined conditions should also work | ||
(:if included groupheader groupfooter sidebar:)
| - | the current text is not included (via (:include:), not via a template) in the specified parts of the page displayed. |
This is very difficult to implement in PmWiki's current model, so it's not likely to be added soon. PmWiki doesn't keep track of the source of each markup, and nested includes pose a bit of a problem.
Pm
Would it be possible to implement a really simple part of it, eg included or not?
The new link and page-variable handling code now renders this issue obsolete.
Pm --- Please give an example of how this issue is solved? See SpecialReferencesSource for the difficulty involved.
I'd suggest the "included" test simply be "source pagename" <> "target (current) pagename", regardless of if target is body, sidebar, footer, header, etc.
thanks
Simon
Simon, the "current" pagename is always the the name of the page you are browsing (it will be SideBar or Footer when you point your browser to that address). The Source pagename is, with $EnableRelativePageVars
, the name of the page where the code is written.
From your examples on the Test group, I'm not sure I understand precisely what you are trying to achieve. Is it "When I browse MyPage I don't want a snippet of it to show in the SideBar"? Is it "When I browse MyPage, I don't want a snippet of it to show, because it is already in the SideBar"? Is it something else for which you want to "detect that the included text is not in the body of a page"?
In the first case, you could use in the sidebar:
(:if name MyPage:) I detected that the text is in the body of the page. (:else:) (:include MyPage:) (:if:)
or
(:include MyPage self=0:)
In the second case, just place (:if false:)...(:if:)
around the snippet anchor. --Petko September 27, 2011, at 04:49 AM