PITS / 01344: Add pagelist iterator | Discuss Page Recent Changes Printable View Page History Edit Page |
Summary: Add pagelist iterator
Created: 2014-04-21 04:21
Status: Open
Category: Feature
From: VKrishn
Assigned:
Priority: 554
Version:
OS:
Description: eg. (:pagelist iterator=[+/-]start,[+/-]end,[+/-]step :) eg. (:pagelist iterator=1,10,1 :) alternate eg. (:pagelist for=[+/-]start,[+/-]end,[+/-]step :) value list eg. (:pagelist for="a b c" :) or e.g. (:pagelist istart=[+/-]startvalue iend=[+/-]endvalue istep=[+/-]stepvalue :) demo - CopyPasteCalendar-Talk With a simple pagelist iterator, it becomes easy to do some interesting things with current template directives. Seems very nice to have in core than as a recipe. Another way might be to use Page List Templates directives, e.g. (:template iterator istart=n iend=n istep=n:) (:template iteratorstart:) !!! {$$istart} (:template each:) {$$ivalue} (:template iteratorend:) {{$$icount} output from {$$istart} to {{$$iend} with {$$istep} (:template iteratorend:) One can use count=num to achieve the same but I believe a pure iterator would be less expensive and faster. (:pagelist count=10 :) If it can be done in any other way please do point to the docs. Thanks. VKrishn April 21, 2014, at 04:30 AM I'd love such a feature as well. In my CopyPasteCalendar recipe I repeat the same line 28 times instead (plus 3 more times in a slightly modified form). I could have used the page list count feature instead. Anyway I wonder whether this might cause problems in a wiki installation with less than 28 pages in total (could only happen in a wiki with no documentation installed I guess). StefCT April 21, 2014
I'd like this feature, with access to the counter that is not driven by the number of pages encountered by the pagelist, e.g. I'd like to, say, iterate for all years to 2000 to 2010 simon September 18, 2014, at 07:53 PM; e.g.
(:pagelist iterate=2000...2008) fmt=#mylist:) [[#mylist]] (:template first {$$Iterator}:) !! From {$$Iterator} (:template each:) (:pagelist name={$$Iterator}* fmt=#titlesummary:) [[#mylistend]] For the alternative suggestion The count=start..end parameter accepts more than just a number. $MarkupExpr['mod'] = '0 + ($args[0] % $args[1])'; # Wikipedia:Modulo_operation Markup test page demo pls. VKrishn April 21, 2014, at 06:24 AM
Here you go: --Petko April 21, 2014, at 09:37 AM [[#iterator]] (:template first:) (:table border=1:) (:template each:) (:if equal "{(mod {$$PageCount} {$$columns})}" "1":) (:cellnr align=right:) (:else:) (:cell align=right:) (:if:) {$$PageCount}. [[{=$Name}]]\\ (:template last:) (:tableend:) [[#iteratorend]] [[#modpair]] (:if equal {(mod {$$PageCount} 2)} 0:) * {=$Name} {=$:Summary} (:ifend:) [[#modpairend]]
This example shows the flaw of using count as an iterator, as there has to be at least as many pages to count as the numerical value you wish to work with.
Only pairs using "name=" (note that only pair pages are found)
Only pairs using "mod" (note that only pair pages are displayed, from 20 pages found impairs are skipped):
Thanks for Does If yes, then what I meant by pure iterator is slightly different and may not fall into pagelist markup. VKrishn April 21, 2014, at 10:03 AM No, the last pagelist does not read all 20 pages (=does not open all 20 files). It only sees the first 20 pagenames. What is read from the disk files depends on the #modpair template, in the example we want to display a {=$:PTV}, then only 10 disk files will be opened from the 20 pagenames. --Petko April 21, 2014, at 10:57 AM I was wrong, conditional markup is processed after page variables, so all 20 files are open. --Petko April 21, 2014, at 11:33 AM See Cookbook:BreakPageList for a possible solution and/or a possible starting point for a solution. --Petko April 21, 2014, at 11:33 AM For the pure iterator, in strict implementation I would not expect variables like VKrishn April 21, 2014, at 11:57 AM Ok, I think that you want a special (:loop:) markup, capable to repeat a markup template for a specified number of times. This seams unrelated to PageLists, so the Summary, the Category, and the Priority of this entry should probably be corrected. I don't think that this will be required by many wikis so a recipe will probably be better. This way we can see if there are indeed many users. --Petko April 21, 2014, at 12:24 PM What happens when fmt=? block does not have variables like [[#modpair3]] (:if equal {(mod {$$PageCount} 2)} 0:) * {$$PageCount} (:if:) [[#modpair3end]] It might not be a pagelist implementation in strict sense. But still think to be a CoreCandidate. Option pagelist for=? can be added that performs partial functionality of pagelist. Hmm.. apology for marking category to "CoreCandidate" just picked form the form , thought any new issue could have such status set by user. Now changed to Feature. VKrishn April 21, 2014, at 12:42 PM Well, you can test it and see. The following will find only a few pages, less then the 'count' value, and will display the pair ones.
Yes, the pagelist markup iterates on existing pages only, regardless of the content of the template. If there are fewer pages than the count= parameter, fewer iterations of the template will be displayed. --Petko April 21, 2014, at 12:54 PM Thanks. No, this one #modpair3 does not open the two (2, 4) or five (0, 1, 2, 3, 4) files, because inside the template there is no markup that requires this - no PageTextVars, no includes, no titles, etc. The first one #modpair opens them because it contains {=$:Summary}. --Petko April 21, 2014, at 01:05 PM hmm... thanks, then would leave it as feature avaiting more votes. VKrishn April 21, 2014, at 01:13 PM |
Main sidebar
|