Difference between revisions of "Issue:Problem with count & includematch"
(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...) |
|||
(One intermediate revision by one other user not shown) | |||
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>{{# | + | :<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 20: | Line 20: | ||
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 == | ||
− | + | A good suggestion! I probably will make it part of the next release. [[User:Gero|Gero]] 22:57, 22 February 2009 (UTC) |
Latest revision as of 23:57, 22 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
A good suggestion! I probably will make it part of the next release. Gero 22:57, 22 February 2009 (UTC)