Extension talk:Semantic Forms/Example

From mediawiki.org

I'd like to know your opinions on how to name properties:[edit]

  • For Authors, why not call the property "Author" instead of "Was written by"?
  • For Genres, why not call the property "Genre" instead of "Has genre"?

Are there guidelines on how to name semantic properties?

Well, I like to name properties as prepositions (a) so it makes sense in a sentence, (b) so it's obvious what the relationship is, and (c) to differentiate them from template fields, which are probably called "Author", etc. There are no guidelines, but if you want to, you can think of that as a guideline. Yaron Koren 16:02, 8 July 2008 (UTC)Reply


And why not:

Book:Author

Book:Year

Book:Genre

Since book is always string. Can I do that?

Great example -- next to do, a demo[edit]

Great example -- and tool. Can't wait to use it. Would be nice to have a 'demo' as well. Furthermore, would be nice to see how others are able to leverage these concepts at various other wikis. Rauterkus 12:27, 21 November 2008 (UTC)Reply

Hi, did you see this section? Also, there are various links in the documentation to discoursedb.org, which currently serves as the main demo wiki. Yaron Koren 15:03, 24 November 2008 (UTC)Reply
Here's a demo linked from the page Yaron mentions above: http://discoursedb.org/w/index.php?title=Picture_IDs_are_perfectly_sensible&action=formedit Pjrich (talk) 20:07, 30 April 2012 (UTC)Reply

AddData[edit]

Hi, I made my first experiences with semantic mediawiki with this example - everything works fine except if I add data. If I add a book page I have a red link to its author - yes, but it doesn't point to the "Author" form - refresh page doesn't help. If I create a new page with Author form it's ok. Next problem is, that I don't see a list of the books from the author, but if i query the author via wiki-browser I get the list of books. My Wikiversion is 1.13. What could I have made wrong?? - --Ulli 757 10:27, 17 January 2009 (UTC)Reply

if I make a new save from the author's page it works - but that's not what I want - --Ulli 757 10:20, 18 January 2009 (UTC)Reply

Did you follow all the instructions exactly? Unfortunately, without access to your wiki, there's not much I can do to diagnose the problem. You could always create a public wiki on Referata, and try to duplicate the problem there. Yaron Koren 17:12, 18 January 2009 (UTC)Reply

I tried to reproduce my bug on referata.com (once with "Bücher" and once with "Books" - probably I do something wrong but I don't know what. My book is "Lockruf der Wildnis" from Jack London, Jack London has a red Link on my books and if I click to Jack London I expect that the new page should open with the authors form, but the new page is empty - --Ulli 757 20:01, 18 January 2009 (UTC)Reply

Hi - you need to add the "Has default form" call to the "Was written by" property. Was that part confusing in the instructions? Yaron Koren 01:07, 19 January 2009 (UTC)Reply

Hi, It works fine now - have a lot of thanks - It was my mistake, I didn't recognize that I have to add the link manually; in the section "Enable links to form" I just read "nothing to change with MediaWiki 1.13" and didn't read the rest. (next time I will print english text instead of reading on monitor...) - thank you and best regards --Ulli 757 06:23, 19 January 2009 (UTC)Reply

Okay, cool. I can see how that text would be confusing - I tried to improve it just now. Yaron Koren 14:10, 19 January 2009 (UTC)Reply

yes, nowbody is able to skip the text know :-) - I am very fascinated by this technique and after some more experience I will design a datastructure and implement Semantic Media Wiki and Semantic Form to my wiki. I watched some "semantic wikis". Some of them have a weak performance. I wonder if this is more a question of weak infrastructure or more a question of weak datadesign? In any case, I would like to warmly thank for your extension and semantic web - I didn't knew it before. - --Ulli 757 18:51, 19 January 2009 (UTC)Reply

I don't know - performance isn't really my specialty. And I don't know if I can take credit for the semantic web, but thanks. :) Yaron Koren 03:03, 20 January 2009 (UTC)Reply

Hi here on the Add Data: how do i add the data? if i type something on search box and click on go; im not getting the author form. Unless i go to the Special Page -> List of Pages -> Forms. Thanks

Yes - you add data by starting out on one of the form pages. Yaron Koren 03:37, 26 June 2011 (UTC)Reply

Property field[edit]

Instructions are fine, thank you very much. Just one question. When I'm going to choose the property it isn't there unless I created it first (is that right?). Andonce I create the property what type do I give it? SInce it's gonna create a link by itself, if I choose "Page" would it cause a conflict somewhere. Just confused about that. Thanks in advance for answer. --Mark 08:37, 13 December 2009 (UTC)

Yes, that's right. And if you're not sure what type to give a property, I would go with "String". Yaron Koren 02:22, 14 December 2009 (UTC)Reply
Thanks Yaron, you paved my way to semantic SUCCESS :) --Mark 13:42, 15 December 2009 (UTC)

Author Template[edit]

Thanks a lot for the example, I am still learning on the SMW stuff, and am liking it.

There is a tiny bit of confsion when you say add data the add data page in SMW gives text on how to do it, etc. No big deal, I went to the category (in my case books) and clicked the form link from there and I went on fine.

I followed your steps to the T. I first entered an Author (James Fenimore Cooper) filled out the form. I then added a book (The Pioneers: The Sources of the Susquehanna; a Descriptive Tale) I then went to the Author's page and the book did not come up. I went to the template and saw that Extension:Semantic Forms/Example was being used in.

<noinclude>
This is the "Author" template.
It should be called in the following format:
<pre>
{{Author
|Country=
}}
</pre>
Edit the page to see the template text.
</noinclude><includeonly>
{| class="wikitable"
! Country of origin
| [[Is from country::{{{Country|}}}]]
|-
! Books by this author
| {{#ask:[[Was written by::{{SUBJECTPAGENAME}}]]|format=list}}
|}

[[Category:Authors]]
</includeonly>
 

The book did not show, I changed it to {{PAGENAME}} and it worked fine.

Could this be because of the namespace? mine should stil be (main).

The whole thing works fine, and having {{PAGENAME}} in it is not a problem for me specifically, just wanted to let you know. Thanks Ojmorales0002 01:05, 18 December 2009 (UTC)Reply


Links in data added through the 'Form'[edit]

Hello again. Following your example, which is the best thing out there for SMW (honestly) since seeing it in action is great. When I add a [[Link]] to something I put in the Book or Author form, any field, I get [[''Property name''::''LINK'']] On the page

Should I be writting the links in another format?

Thanks Ojmorales0002 03:34, 20 December 2009 (UTC)Reply

It sounds like SMW isn't parsing it - is SMW running at all? Yaron Koren 21:44, 20 December 2009 (UTC)Reply
Hi Yaron, yes SMW is up and running, I've created a few of everything, Properties, Types, Forms, Templates, etc. I am trying to find soewhere to host it so I can show you better. Let me see if I can explain it better.

In your example there is a step to:

Country of origin - you create a property called "Is from country", of type "String".

I follow your instructions, they are fine, I use the form to create a page "Omar M" in the Country I put in USA. All works as planned. however if I enter:

[[USA]]
 

It shows me:

[[Is from country::USA]]
 

The link to create the USA article is a redlink. I know the Property type is String. I thought that String and Text accepted Wiki syntax. I just want to know either way, to find a solution for this. Thanks.

Also, if you dont mind I might post some 'Acutal Use' examples for some of the manual sections.

Ojmorales0002 01:01, 21 December 2009 (UTC)Reply

Oh, I think I understand - you need to add "$smwgLinksInValues = true;" to your LocalSettings.php file. Yaron Koren 02:27, 21 December 2009 (UTC)Reply
You rock. That fixed it, I can add Links and URLs. If you don't mind me asking where wouold I have found the information for that config line? Ojmorales0002 02:43, 21 December 2009 (UTC)Reply
Cool. It's listed in the SMW Help:Configuration page - which is admittedly very hard to find. I'd recommend using the "SMW Quick Reference" guide, which I created - you can download it in both PNG and PDF form. Yaron Koren 11:38, 21 December 2009 (UTC)Reply

Enable Links to forms Section?[edit]

In the part where it describes how to enable links to forms there is a reference to "was written by" property page? What and where is this property page?

It would be the page called "Property:Was written by". Yaron Koren 03:06, 28 July 2010 (UTC)Reply

Edit in the same form[edit]

Good tutorial!

But I have some questions,when i go to Book form to add the book lets call it Lord of the Rings, i see the form Authors: Genres:Year: Number of pages ...
I add the book, now when i added the book I go to that Lord of the Rings book page, now when i click edit button it shows me this code: {{Book |Authors=Pott M. Joule |Genres=Mistory<br> |Year=2006 |Number of pages=1021 }}

So here is my question, is there a way i can edit that Lord of the Rings book page in the same form that i added instead just seeing this code? Alex

Yes - it's explained in the example, although very briefly (probably too briefly). You need to set in both categories their respective as their default form - you should add something like "[[Has default form::Book]]" to the Books category, for instance. If you use Special:CreateCategory, there's an option for that. Yaron Koren 07:07, 24 October 2010 (UTC)Reply
Thank you, it worked great!
Alex

Edit link for each field[edit]

If it is possible, is there a way that each field ex. Authors:, Genres:,... have its own edit link? For ex. if i want to edit specific field such as "Authors" i need to edit the whole article by clicking on "edit with form" instead i want to have "edit" link for each field, one for Authors, one for Geners and ect. I don't know maybe there is a special module to this module that provides this kind of feature.

I tried to use Book Form first and later realized that it just edits the book form and not the output of the information. So, then I saw a Template_Book, I tried editing the code by adding ==== around this code {{#arraymap:{{{Authors|}}}|,|x|[[Was written by::x]]}}, so everything worked fine, a saw the [edit] link around the Authors, But, after clicking the edit link I realised that it just edits the variable and not the authors name, for ex. instead of seeing this |Authors=Mark Volkov i saw this | {{#arraymap:{{{Authors|}}}|,|x|[[Was written by::x]]}}. So far I got stuck... any help is appreciated.
You can create additional forms that only contain that one field, and then have the page (via the template) link from each field in the page to the relevant form to edit that one field. Personally, I don't see the problem in just having one big form for anything, but that's a matter of taste. Yaron Koren 02:15, 1 November 2010 (UTC)Reply
I didn't really fallowed this "... then have the page (via the template) link from each field in the page to the relevant form to edit that one field." Can you provide steps/tutorial demonstrating what you said above, lets say using authors field? If you have time that is. And, I also what to thank you for you help, not that you just helped me with my questions, but I also start to understand better mediawiki and semantic form extension.
The basic idea is, you create a bunch of "mini-forms", one for each field, and then have the page link to each one. Yaron Koren 14:02, 1 November 2010 (UTC)Reply
Ok, so I created forms, and I still don't get this part "then have the page link to each one". Is it by copying the code from one of the form templates and placing it in the main page where all the mini forms will be placed?
Ow boy, ok so I tried to figure this step by myself again and I think I failed, while I was looking at Create a property page I noticed that there an option similar to what your step is telling me to do, This property will link to pages that use the form: but it talks about linking properties to form, and nothing about forms linking to pages, so obviously I am in a wrong place. So, then I looked at this tutorial again, and focused on Enable links to forms step thinking maybe I should be adding type of the code like this [[Has default form::Form:Author]] to the page, maybe this is what you said by linking forms to pages, but again this code tag doesn't make sense. unless there is another code tag I am suppose to use that I don't know about. Once again I am stuck.
Hi - I mean that you should be modifying the template, so that it adds links to each of those forms, within each page that uses the template. Yaron Koren 18:03, 9 November 2010 (UTC)Reply
Can you provide at least one example on how to do what you telling me to do with the tutorial that you wrote? For ex. using Authors and Genres as the seperate forms.


This is so far what I got, what kind of code do I need to add to the templates? From where and to what?
Step 1: For properties I have created:
  • Author(s) - using the "Create a property" page, I created a property called "Was written by", of type "Page" (since each author will have his/her own page).
  • Genre - I created a property called "Has genre", of type "String", and gave it allowed values such as: "Art, Cookbook, Fiction...".
Step 2: For templates I have created 2 templates:
  • I set the field name to be "Authors_temp", the label to be "Author(s)" and the semantic property to be "Was written by", and checked the box indicating that this field can hold a list of values;
SEPERATE TEMPLATE
  • I set the three values to be "Genres_temp", "Genre(s)" and "Has genre", and also check the box for a list of values.
Step 3: For forms I created two differetn forms:
  • Authors_form - using the "Create a form" page, I made a form called "Authors_form", and added to it the template "Authors_temp".
  • Genres_form - using the "Create a form" page, I made a form called "Genres_form", and added to it the template "Genres_temp".
This is what I got in my Authors template (Authors temp)
<noinclude>
This is the "Authors_temp" template.
It should be called in the following format:

{{Authors_temp
|Authors=
}}

Edit the page to see the template text.
</noinclude><includeonly>
{| class="wikitable"
! Author(s)
| {{#arraymap:{{{Authors|}}}|,|x|[[Was written by::x]]}}
|}
</includeonly>
This is what I got in my Genres template (Genres temp)
<noinclude>
This is the "Genres_temp" template.
It should be called in the following format:

{{Genres_temp
|Genres=
}}

Edit the page to see the template text.
</noinclude><includeonly>
{| class="wikitable"
! Genre(s)
| {{#arraymap:{{{Genres|}}}|,|x|[[Has genre::x]]}}
|}
</includeonly>


I will probably have to use this code to link to form, but for some reason it doesn't take me to the form I want
<span class="editsection plainlinks" style="float:right;margin-left:5px;">
[[{{fullurl:{{{2|{{{page|{{FULLPAGENAME}}}}}}}}|action=edit&section={{{1|{{{section|0}}}}}}}} 
<font color="#002bb8">edit</font>]]</span></nowiki>
I did rename action=edit to action=formedit so the code should work, then again even if I type in into the brawser index.php?title=test_page&action=formedit url I get to the page that says "No such action"....
Come on Yaron Koren give me a hand, I already tried so many things that I didn't even mansion here and still can't get it to work, maybe there is a tutorial or example that you know that will help me going...

The URL you should be linking to should be of the form "Special:FormEdit/form name/page name". If that still doesn't work, I'd suggest writing to the semediawiki-user mailing list about it. Yaron Koren 06:25, 21 November 2010 (UTC)Reply

Ok, here is what I got "index.php/Special:FormEdit/Authors_form/Author_and_Genera" Authors_form is the name of the form, Authors_and_Genera is the title of the article. Now how do I translate this into this kind of url
[[{{fullurl:{{{2|{{{page|{{FULLPAGENAME}}}}}}}}|action=formedit}} edit]]
So, FULLPAGENAME is the title of the page which is Authors_and_Genera, Authors_form form is not even included in this url, and i don't know even where to put it in the code, I tried but it just does't get me to the page I want, so I am obviously making some king of mistake, if someone can help me set up the url that suppose to go into the template I would really appreciate it.
Can someone help me construct the url? Or at least show me the article or tutorials that show you how to work with this kind of urls, I already read a few mediawiki articles on this but still have no clue how to do it.
As I wrote, "action=formedit" should not be in the URL - the URL should be of the form I gave before. Yaron Koren 13:15, 29 November 2010 (UTC)Reply
This is the URL I end up using:
[{{#formlink:form=Authors_form/{{PAGENAME}}|link text=edit|link type=link}}]
Or
[[{{fullurl:Special:FormEdit/Authors_form/{{PAGENAME}}}} edit]]
I don't know if it is correct form but it is working.

WYSIWYG demo[edit]

This tutorial is completely incomprehensible. What is needed is a screen capture video or slideshow showing the actual creation of the Semantic form. 201.81.181.66 11:33, 21 April 2011 (UTC)Reply

Edit Form with Form[edit]

Using Special:CreateForm i can get a form for creating other forms. Now when my form is created and i want to go back and edit it i only get code not the form that came with "CreateForm". How do i get this form back to edit my other forms (to say change a text length or if a value is required).

You can't do that, unfortunately. But a new extension I'm involved with, Page Schemas, is (hopefully) going to provide a solution to that problem. Yaron Koren 03:49, 7 September 2011 (UTC)Reply

Example: Click on Author (red link) does not use Form:Author[edit]

As per title. If I create the author page using Form:Author, the link (was red link) is able to link correctly. What is wrong?

Property:Was_written_by

This is a property of type [[Has type::Page]].
The default form is [[Form:Author]]. {{#default_form:Author}}
 

Template:Book

<noinclude>
This is the "Book" template.
It should be called in the following format:
<pre>
{{Book
|Authors=
|Genre=
|Year=
|Number of pages=
}}
</pre>
Edit the page to see the template text.
</noinclude><includeonly>{| class="wikitable"
! Author(s)
| {{#arraymap:{{{Authors|}}}|,|x|[[Was written by::x]]}}
|-
! Genre(s)
| {{#arraymap:{{{Genre|}}}|,|x|[[Has genre::x]]}}
|-
! Year of publication
| [[Was published in year::{{{Year|}}}]] 
|-
! Number of pages
| [[Has number of pages::{{{Number of pages|}}}]] 
|}

[[Category:Books]]
</includeonly>
 

Book:Form

<noinclude>
This is the "Book" form.
To create a page with this form, enter the page name below;
if a page with that name already exists, you will be sent to a form to edit that page.


{{#forminput:form=Book|placeholder=Title of book}}

</noinclude>

<includeonly>

<div id="wikiPreview" style="display: none; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid #AAAAAA;"></div>

{{{for template|Book}}}
{| class="formtable"
! Authors: 
| {{{field|Authors}}}
|-
! Genre: 
| {{{field|Genre}}}
|-
! Year: 
| {{{field|Year}}}
|-
! Number of pages: 
| {{{field|Number of pages}}}
|}
{{{end template}}}

'''Free text:'''

{{{standard input|free text|rows=10}}}

{{{standard input|summary}}}

{{{standard input|minor edit}}} {{{standard input|watch}}}

{{{standard input|save}}} {{{standard input|preview}}} {{{standard input|changes}}} {{{standard input|cancel}}}
</includeonly>
 

--Yoonghm (talk) 15:10, 20 September 2015 (UTC)Reply

I added the following to "enable" semantic links and annotations but does not work in LocalSettings.php, following https://semantic-mediawiki.org/wiki/Help:$smwgNamespacesWithSemanticLinks
$smwgNamespacesWithSemanticLinks[SWM_NS_PROPERTY] = true;
$smwgNamespacesWithSemanticLinks[SWM_NS_TYPE] = true;
$smwgNamespacesWithSemanticLinks[SWM_NS_CONCEPT] = true;
$smwgNamespacesWithSemanticLinks[SF_NS_FORM] = true;
 

--Yoonghm (talk) 17:03, 20 September 2015 (UTC)Reply

I completely forgot about this page! It's not linked to from the rest of the documentation. I just blanked it. As for your question - it sounds like an actual SF question, so the main SF talk page might be the right place for it. Yaron Koren (talk) 15:25, 21 September 2015 (UTC)Reply