Help talk:Subobjects and queries
- [View source↑]
- [History↑]
Contents
Thread title | Replies | Last modified |
---|---|---|
Integrate Subobject Queries into Ask? | 1 | 09:16, 18 September 2013 |
More natural way | 2 | 09:21, 15 June 2013 |
It seems to me that querying for page properties and subobjects simultaneously is needlessly complicated. Having to perform sub-queries inside other templates just obfuscates the code unnecessarily. Couldn't something like below be implemented? Is there some technical reason this wouldn't work? I've written this as a separate parser function from #ask (since I'm considering writing an extension), but it seems this could integrate with #ask.
{{#sub_ask: [[Category:Recipe]] |? Title |? Author |? Person#sub: [[Has ingredient::+]] <== notes [1] [2] [3] |? Has quantity |? Has unit |? Has ingredient | format=template | template=Part of recipe <== note [3] #end_sub | format=template | template=Recipe }} [1] Implicitly does [[-Has subobject::<PAGENAME>]] [2] [[Has ingredient::+]] not needed if "Part of recipe" subobjects are the only kind on the page [3] Each subobject will get passed to the template "Part of recipe", and the output of each will be concatenated and set as the value of {{{Person}}} within the "Recipe" template
Is there some reason something like this wouldn't work or wouldn't be a good idea to implement in an extension or future release of SMW?
Similar concerns here. By now I must have lots of templates for subqueries in templates for queries and it's not easy to keep track which of these are still being used and where. Perhaps a cleaner solution syntax-wise (so that you won't have to embed things) is to have a new result format which points to a variable on the page. Anyway, you'll have a better chance getting attention from devs and a wider response if you post to the mailing list.
Wouldn't it be more natural to have a subobject's property pointing at the parent page and query the latter's properties by chaining?
I thought about this too in the beginning (see this thread).
I tried to query for |?has subobject.PropertyOfParent but this didn't work.
Maybe I would have to create a subobject property holding the parent page and then query for that one.
Can someone try it and adapt the page? :)
Advantage of my proposed solution: It doesn't need another property.
Yes, I meant creating a property for subobject to backreference the parent page, then querying ?MyParentPage.PropertyOfParent
. That's SIO way and in many cases such property is more meaningful than the property pointing from the parent page to the subobject. The backreference property may be universal or specific to the subobject class.