ConditionalMarkup-Talk

Markup Shortcut

You can also use an abbreviated form of (:ifend:), (:if:) for brevity:

(:if cond1:) cond1 is true (:if:)
(:if cond1:) cond1 is true (:if cond2:) cond2 is true (:if:)

The latter is identical to :

(:if cond1:) cond1 is true (:ifend:)(:if cond2:) cond2 is true (:ifend:)

Note that the use of (:if:) without parameters and (:ifend:) is identical.

Is it possible to test for a specific query parameter in the URL, e.g. test for the value of "group=" when a PmWiki search returns? Perhaps (:if URLQ group <value>:)

Isn't Request what you are looking for ? --gb

There might be {$$group} available in a PageList template if you have request=1 so you may be able to do (:if equal "{$$group}" "Main":) in the template. There is also Cookbook:HttpVariables. --Petko

How can I test if a file is being included? I want to omit part of the page if it is included.

If you mean how can you know if the page is being displayed normally versus via inclusion, you can test like this in the part of the page you wish to omit: (:if equal "{*$FullName}" "{$FullName}":) - when the part is being displayed on another page they won't be equal.

Where is the difference between round and square brackets in combined conditions?

see Conditional Markup. Use round brackets (not square) for nested expressions

Can specific attachments be tested for existence?

eg (:if attachments descriptor='*.jpg,*.jpeg':) see ConditionalMarkupSamples

Can attachments on a specific page be tested for existence?

eg (:if attachments Group.PageName:) yes, see Conditional Markup

Can a numerical expression be tested for?

eg (:if {(strlen "{$:Summary}")} < 20:) ?

How can I achieve (:if link=Category/Something:)

see if the Page Lists link= and category= parameters can be used

Is it possible to test for (:if skin myskin:)

Some skins set a PHP variable that can be tested using (:if enabled VAR:)

How do you specify the REGEX in the match expression? In testing if the page name ends in "-Talk", I've tried "-Talk$", /-Talk$/ and "/-Talk$/" and none of them seem to work. tamouse November 09, 2011, at 05:47 AM

It seems to work below:

(:if match -Talk$:)
This is a talk page.
(:else:)
This is not a talk page.
(:if:)

This is a talk page.

Obviously, for this exact conditional you have the easier and more robust name= parameter. --Petko November 09, 2011, at 04:37 PM

(:if name *-Talk:)
This is a talk page.
(:else:)
This is not a talk page.
(:if:)

This is a talk page.

is it possible to say (:if ! (EXPRESSION) :)?

yes, e.g. (:if ! expr (EXPRESSION) :), see Conditional Markup

Neither (:if name "{*$SubpageParent}?day?,{*$SubpageParent}?day??,{*$SubpageParent}?maps":) or (:if name '{*$SubpageParent}?day?','{*$SubpageParent}?day??','{*$SubpageParent}?maps':) seems to work, the quotes are needed as the variable may have spaces in it, is there a solution for this?

You may be able to have a regular expression like (:if match .(day..?|maps)$:) but if you can't you should ask this on the talk page of the specific addon that introduces these patterns and variables. --Petko April 28, 2019, at 09:25 AM

Date examples

* {(ftime fmt="%F" when="yesterday")} - yesterday
* {(ftime fmt="%F" when="today")}     - today
* {(ftime fmt="%F" when="tomorrow")}  - tomorrow

''Evaluates to true if VALUE is within DATE'' \\
{(ftime fmt="%Y" when="tomorrow")} (:if date {(ftime fmt="%F" when="today")} {(ftime fmt="%Y" when="tomorrow")}:) ''is'' (:else:) is not (:ifend:) within {(ftime fmt="%F" when="today")} \\
{(ftime fmt="%m" when="tomorrow")} (:if date {(ftime fmt="%F" when="today")} {(ftime fmt="%m" when="tomorrow")}:) ''is'' (:else:) is not (:ifend:) within {(ftime fmt="%F" when="today")} \\
{(ftime fmt="%Y-%m" when="tomorrow")} (:if date {(ftime fmt="%F" when="today")} {(ftime fmt="%Y-%m" when="tomorrow")}:) ''is'' (:else:) is not (:ifend:) within {(ftime fmt="%F" when="today")} 

''true if VALUE (or current date if omitted) is DATE1 or later (unlimited)'' \\
(:if date {(ftime fmt="%F" when="yesterday")}.. :) today is after yesterday (:ifend:)

''true if VALUE (or current date if omitted) is DATE2 or earlier (unlimited)'' \\
(:if date ..{(ftime fmt="%F" when="tomorrow")} :) today is before tomorrow (:ifend:)

''true if VALUE (or current date if omitted) is in range DATE1 to DATE2 (inclusive)'' \\
(:if date {(ftime fmt="%F" when="yesterday")}..{(ftime fmt="%F" when="tomorrow")} :) today is between yesterday and tomorrow (:ifend:)
  • 2024-02-25 - yesterday
  • 2024-02-26 - today
  • 2024-02-27 - tomorrow

Evaluates to true if VALUE is within DATE
2024 is within 2024-02-26
02 is not within 2024-02-26
2024-02 is not within 2024-02-26

true if VALUE (or current date if omitted) is DATE1 or later (unlimited)
today is after yesterday

true if VALUE (or current date if omitted) is DATE2 or earlier (unlimited)
today is before tomorrow

true if VALUE (or current date if omitted) is in range DATE1 to DATE2 (inclusive)
today is between yesterday and tomorrow


This is a talk page for improving PmWiki.ConditionalMarkup.