Familypedia
Forums: Index > Help desk > SMW ask query


Hi :) I'm an editor from another wiki, but I've found the SMW documentation here to be much better than anywhere else, so I'm trying to use it for my own templates. However, I've ran into a strange issue, and I'm hoping that someone could help me understand what am I doing wrong.

I'm trying to set up a simple "ask" function. It's supposed to display the pagenames of several annotated pages on one page, but each displayed pagename should be inserted into a [[Property::]] format as well.


For example: Page 1, Page 2, Page 3 all have the annotation [[Next::Page 4]].
Page 4 should display all three page names as links, and add [[Previous::Page 1]], [[Previous::Page 2]], [[Previous::Page 3]] as well.

I managed to set it up to display the links, but it doesn't add the Previous:: properties for some reason.

I use this template to display the page names, and a separate "Prev" template below that supposedly should put each result into a property format:

{{#if: {{#ask: [[Next::{{PAGENAMEE}}]]|link=none}}|{{#ask: [[Next::{{PAGENAMEE}}]]|link=none|format=list|template=Prev}}|}}
Prev template: [[Previous::{{{1|}}}]]

Any tips on why it isn't working? I would apreciate any help. --IcecreamKitten 04:49, February 3, 2011 (UTC)

Next is a multi-valued property. You should use arraymaptemplate. See {{Given}} for a recent demonstration (on property variants). rtol 06:35, February 3, 2011 (UTC)
Thanks :) Looks like I'll need something like this:
{{#arraymaptemplate:{{#ask: [[Next::{{PAGENAMEE}}]]|format=list}}|Prev|,|,}}
[[Previous::{{{1}}}]]
It appears that my wiki doesn't have the extension that supports the arraymaptemplate, though, judging from a minor test I ran here. I'll ask for it to be enabled and do some more testing (it should be the Semantic Forms if I'm not mistaken). --IcecreamKitten 12:39, February 3, 2011 (UTC)
Wikia staff has enabled the extensions rather fast, so it's finally working. Thanks for the help :) The final code I'm using:
{{#if: {{#ask: [[Next::{{PAGENAMEE}}]]}}| {{#arraymaptemplate:{{#ask: [[Next::{{PAGENAMEE}}]]|link=none|format=list}}|Prev|,|<br />}} |}}
[[Previous::{{{1}}}]]
Perhaps someone could add the arraymap information to the Help pages? This is very useful, and probably one of the first functions that new users might try using. --IcecreamKitten 18:57, February 3, 2011 (UTC)