Difference between revisions of "Issue:Problem with count & includematch"

From FollowTheScore
Jump to: navigation, search
(New page: {{Issue |Type = Change Request |Extension = DPL |Version = 1.7.4 |Description = There is an unanticipated behavior when using param 'count' with param 'includematch', resu...)
 
(Problem)
Line 13: Line 13:
  
 
The workaround I came up with is to pass %NR% to the template call, and put an  
 
The workaround I came up with is to pass %NR% to the template call, and put an  
:<pre><nowiki>{{#if:{{{%NR%}}}<3|* [[{{{%PAGE%}}}}]}}</nowiki></pre>  
+
:<pre><nowiki>{{#ifexpr:{{{%NR%}}}<3|* [[{{{%PAGE%}}}}]}}</nowiki></pre>  
 
into my template.dpl call, which effectively limits the number of returned results to 3 by displaying nothing for %NR%>=3. I had to modify the DPL code ever so slightly to pass the %NR% param to the template, but it appears to work OK.
 
into my template.dpl call, which effectively limits the number of returned results to 3 by displaying nothing for %NR%>=3. I had to modify the DPL code ever so slightly to pass the %NR% param to the template, but it appears to work OK.
  
Line 19: Line 19:
  
 
See detailed DPL query at [http://www.wikidoc.org/index.php/Template:Searchnews wikidoc.org].
 
See detailed DPL query at [http://www.wikidoc.org/index.php/Template:Searchnews wikidoc.org].
 
  
 
== Reply ==
 
== Reply ==

Revision as of 05:45, 18 February 2009

Description: There is an unanticipated behavior when using param 'count' with param 'includematch', resulting in an inability to limit the number of returned results.
Extension / Version: DPL   /   1.7.4
Type / Status: Change Request   /   open

Problem

What I'm trying to achieve is this -- select top 3 pages matching 'includematch'.

When I set 'count=3' in my DPL query, the includematch regex is applied within the MySQL result set (whose query ends with LIMIT 0 3). Thus, I get includematch applied to the top 3 articles in the MySQL query. For most pages, this is very few. Thus, I set count=100 or some other value, and return the number of pages that happen to match.

The workaround I came up with is to pass %NR% to the template call, and put an

{{#ifexpr:{{{%NR%}}}<3|* [[{{{%PAGE%}}}}]}}

into my template.dpl call, which effectively limits the number of returned results to 3 by displaying nothing for %NR%>=3. I had to modify the DPL code ever so slightly to pass the %NR% param to the template, but it appears to work OK.

It would be nice to use another param (like 'limitcount=3') to achieve this more efficiently, so that the Mediawiki parser engine doesn't have to parse every template for %NR%>=3.

See detailed DPL query at wikidoc.org.

Reply