Difference between revisions of "Issue:%PAGES% or %TOTALPAGES% in parser functions"

From FollowTheScore
Jump to: navigation, search
m
Line 48: Line 48:
  
 
== Reply ==
 
== Reply ==
 +
 +
You missed an important concept in DPL: The wiki syntax of the #ifexpr shall only be evaluated AFTER thge DPL statement has been parsed. To achieve this you have to avoid using double curly braces and pipe characters. Instead you have to use the alternate symbols which are resolved in a second pass. See the manual for more details.
 +
 +
<pre><nowiki>
 +
{{#dpl:
 +
|category=Category
 +
|namespace=Category
 +
|count=5
 +
|resultsheader=%TOTALPAGES% are ²{#ifexpr:%TOTALPAGES% < 10¦less than 10 results¦more than 10 results}²
 +
}}
 +
</nowiki></pre>
 +
 +
The above statement will deliver the expected result:
 +
 +
{{#dpl:
 +
|category=Category
 +
|namespace=Category
 +
|count=5
 +
|resultsheader=%TOTALPAGES% are ²{#ifexpr:%TOTALPAGES% < 10¦less than 10 results¦more than 10 results}²
 +
}}

Revision as of 07:53, 9 May 2009

Description: %PAGES% or %TOTALPAGES% in parser functions returns syntax error
Extension / Version: DPL   /   ?
Type / Status: Bug   /   open

Problem

I want to create a navigation template for long DPL result lists. In general no problem, but I fail at detecting the end of the list where no "Next" link should appear. So I'd actually use no link if: totalpages - offset <= count. Simplified example:

{{#dpl:
|category=Category
|namespace=Category
|count=5
|resultsheader=%TOTALPAGES% are {{#ifexpr:%TOTALPAGES% < 10|less than 10 results|more than 10 results}}
}}
9 are Expression error: Unrecognized punctuation character "%".


Or via a template: User:Subfader/NavTemplate

{{#dpl:
|category=Category
|namespace=Category
|count=5
|resultsheader={{User:Subfader/NavTemplate|count=5|totalpages=%TOTALPAGES%}}
}}

User:Subfader/NavTemplate:
{{{totalpages}}} are {{#ifexpr:{{{totalpages}}} < 10|less than 10 results|more than 10 results}}. {{{count}}} displayed.
9 are Expression error: Unrecognized punctuation character "%".. 5 displayed.


Any help would be appreciated. --Subfader 16:13, 8 May 2009 (UTC)

Reply

You missed an important concept in DPL: The wiki syntax of the #ifexpr shall only be evaluated AFTER thge DPL statement has been parsed. To achieve this you have to avoid using double curly braces and pipe characters. Instead you have to use the alternate symbols which are resolved in a second pass. See the manual for more details.

{{#dpl:
|category=Category
|namespace=Category
|count=5
|resultsheader=%TOTALPAGES% are ²{#ifexpr:%TOTALPAGES% < 10¦less than 10 results¦more than 10 results}²
}}

The above statement will deliver the expected result:

9 are less than 10 results