Help talk:Adding subobjects using the Page Forms extension



Thread titleRepliesLast modified
Adding properties to form values...115:52, 18 October 2014
Concrete example would be great119:15, 20 October 2013

Adding properties to form values...

Hi, I have been trying to figure out how subobjects work. Documentation doesn't help me much with the questions: Do I need 2 templates or does it work in only 1? How do I add the properties?

I did the following (simplified), which seems to work:

Box (main) template:

Description: {{{Description|}}}
{{#ask: [[Is part of box::{{PAGENAME}}]] |?Has amount |?Has item |format=table |mainlabel=-}}

Item template:

{{#set: Has amount={{{NUMBER|}}}}} {{#set: Has item={{{ITEM|}}} }}
{{#subobject: |Has item={{{ITEM|}}} |Has amount={{{NUMBER|}}} |Is part of box={{PAGENAME}} }}


{{{for template|Box}}}
{{{end template}}}

{{{for template|Item|multiple}}}
{{{end template}}}

My question now is: Is this somewhat correct? And is there any other way to add the properties (Has item, has amount) to the values (in the item template) instead of setting them silently with #set? If I add them simply with [[Has amount::{{{NUMBER|}}}]] [[Has item::{{{ITEM|}}}]] they will show additionally to the output of the#ask query, which is unintentional, because it's double.

19:00, 16 October 2014

Yes, you need two templates, one for the page and one for the subobjects since there are supposed to be several different items in the box. So you will need to use the multi instance form.

Do not add #set in the item template since you are already passing the respective values to the subobject. I prefer setting all values into the subobject via the form, e.g. by additionally adding {{{field|BOX|hidden|default={{PAGENAME}} }}} but that's probably a matter of habit. Thus I believe it is easier to grasp which values are actually annotated via the subobject.

15:46, 18 October 2014

Concrete example would be great

For a few days I have been trying to get the subobjects feature with forms working. I am stuck at even finding a working example. I was not able to understand the following explanation:

If you want to semantically store all the data contained in these multiple-instance templates, it is recommended to use either the Semantic Internal Objects extension, or, if you have version 1.8 or later of Semantic MediaWiki, subobjects. (If you use subobjects, you should pass in a blank as the first parameter, so that each subobject gets an automatically-assigned name.)

I am using the PageSchema way of creating forms and templates which seems to make things even more difficult. The PageSchema software does not mention any subobject feature.

07:23, 20 October 2013

Hi - unfortunately, Page Schemas doesn't support #subobject yet - that needs to be added. For now, it only supports the similar #set_internal call, in the Semantic Internal Objects extension. So you could either install SIO and re-edit the schema, or modify that multiple-instance template, after it's generated by Page Schemas, by taking out all its current SMW property tags and replacing them with a single #subobject call.

19:15, 20 October 2013