Help talk:Subobjects and queries

Jump to: navigation, search


Thread titleRepliesLast modified
Integrate Subobject Queries into Ask?109:16, 18 September 2013
More natural way209:21, 15 June 2013

Integrate Subobject Queries into Ask?

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]
    |  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?

James Montalvo (talk)05:38, 18 September 2013

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.

Cavila (talk)09:16, 18 September 2013

More natural way

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?

Alex Mashintalk14:38, 14 June 2013

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.

Stefan Seidner (talk)22:50, 14 June 2013

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.

Alex Mashintalk09:21, 15 June 2013