Last modified: 2009-11-03 14:30:10 UTC
With format=template, one has no control over the individual field values passed to your template, it's just the wiki text of each item. In the case of n-ary data, the individual pieces are passed in one, gigantic parameter to the template. One doesn't get the individual pieces of a many-valued property. Someone might want to get the number and units of a linear value separately. The current work around is to install 4+ other extensions and chop of the string and put it in a kind of array. So, if inline queries had a new "parts=exploded" option to send the same individual elements of each value to a template, we would have more formatting control. This would make accessing parts of n-ary data much simpler and not force SMW users to be dependent on so many other extensions of unknown future viability.
As I wrote in message "[Semediawiki-user] enhancement: explode format in query results", it seems like the implementation of this feature could reuse datavalues' existing ability to provide their parts in response to getServiceLinkParams(). It's not as simple as it sounds. E.g. some parts that datatypes return for service links are URL-encoded because service links are specifically for fabricating hyperlinks.
Yeah, to be usable by templates, all linking would have to be stripped. As one can see at http://sandbox.semantic-mediawiki.org/wiki/Comparison_shop, it would be far more useful to split output into individual data points: instead of {{{1}}} being "Best Buy" and {{{2}}} being "[[An Inconvenient Truth]] (20 USD), [[Babel]] (21 USD), [[The Matrix]] (25 USD)", I'm asking for {{{1}}} to be "Best Buy" and {{{2}}} to be "An Inconvenient Truth", {{{3}}} to be "20 USD", {{{4}}} to be "Babel", {{{5}}} to be "21 USD", etc. etc. Would that be very complicated? It seems like it would just be a matter of returning each part of an n-ary according to it's type.
Perhaps this would be more helpful: == Pseudocode == # Compile the n-ary data as normal to be sent to the template # Create an array for each n-ary property # Set array to the values obtained by splitting on ")," # Split each array element on "," # Split the first element in each array on "(" # Send each element of each array in turn as the next parameter, along with other data
Re-assign to extension developer for triage/comments.
My preferred solution would be to be able to specify printouts not only for all parts of a multi-valued property, but also for selected components. Doing this, you could emulate your solution by just using multiple printouts, each for one of your data items. On the other hand, you could also customise the whole output to use only some of the components at all. The implementation of this depends on Bug 16571.
It is now possible to write "|+index=value" after some print request for multi-valued properties to obtain only one of the parts. Indexes range from 1 to the number of values that the property takes. This can be used to pass individual values to some template result formatter as well. The bug will thus be closed, although some open issues remain for printout parameters in general (see Bug 16571).