Similarly, I have another query that is truly iterative. (this uses a 'Has
child' property that is derived elsewhere using a query on the Has parent
property). This requires only 3 pages and is run from within the pages being
queried to determine the name of the page that is the ultimate (top level)
parent of the current page.
The first page initiates the iterator:
==Top level project==
{{#vardefine:currentpage|{{PAGENAME}}}}
{{UltimateParentQuery}}
[[Ultimate parent::{{#var:ultimateparent}}]]
This initiates the variable being searched on (<currentpage>) and calls the
query page (Template:UltimateParentQuery):
{{#ask: [[Category:Research Projects]][[Has
child::{{#var:currentpage}}]][[Has child::+]]
|format=template
|link=none
|default={{#vardefine:ultimateparent|{{#var:currentpage}}}}
|template=UltimateParent
|limit=1
}}
This searches for the page that has the property Has child:<currentpage>. If
there is no result, <currentpage> is written out. If there is a result, this
is sent to to Template:UltimateParent:
{{#vardefine:currentpage|{{{1|}}}}}
{{UltimateParentQuery}}
which sets <currentpage> to the result and re-runs the query.
This should continue until the top level parent is found. However, it fails
after 3 iterations. This means that for 4th generation pages and beyond, the
grandparent's page name is written out.
Again, can anyone see why this fails at the 3rd iteration?
--
View this message in context: http://www.nabble.com/Iterating-queries---go-%27phut%27-at-3rd-iteration-tp20915048p20916159.html
Sent from the Semantic Mediawiki - User mailing list archive at Nabble.com.
|