Discuss Help:Setting values using #set

From semantic-mediawiki.org

Please note that using the {{#set:}} parser function, while it hides links on the subject page, if the page is transcluded via an embed query, the property that has been set with {{#set:}} will be transcluded as well--the same is not true of properties wrapped in a conventional hidden link, e.g., [[Some property::object page| ]].

Developers, please allow this behavior to continue, as it is very desirable and offers a great deal of flexibility! Edited 2011-02-10 in response to this email thread

--Alex 19:48, 9 February 2011 (CET)


The above behavior has been reported and acknowledged as a bug, not a feature. Therefore, for the time being, you must either wrap your {{#set functions in noinclude tags or mark them as silent annotations, e.g., [[Property::value| ]] --Alex 19:36, 10 February 2011 (CET)


Thread titleRepliesLast modified
Setting multiple values in one turn123:13, 2 January 2016
Template parameter204:40, 17 March 2015
Practical example218:21, 24 January 2015
parser in #set 1300:16, 7 January 2013

Setting multiple values in one turn

Dabbling a little bit with some old templates of mine I found out that


can be used to store multiple values for one property. Since I did not find any mention of it as I wanted to confirm this, I would like to ask, whether this is a solid feature (and remains so) or is it unwanted and will be removed somewhen?

22:46, 2 January 2016

Template parameter

I still don't get it.

04:28, 16 March 2015

> I still don't get it.

Well then you probably don't need it but some background can be found at [0].

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/756

14:48, 16 March 2015

Now I get it. This is meant to enable adding some fancy formatting or navigation to semantic infoboxes.

This is really an important task. In my projects, I solve it with regular expressions, which is really costly.

But I don't think that {{#set:}}, originally meant for silent annotations, should be charged with it.

Also, I think that parsing passed values is not about splitting their lists only. This is more complex task involving dealing with alternative texts (after |), footnotes and other accompanying text.

04:39, 17 March 2015

Practical example

Hi, don't want to abuse this for self-marketing but as for us it would be helpful to see practical examples of how certain features can be used I thought we could also help others by adding something like this to the description:
Enter a new replication to the ReplicationWiki [1] [2]
What do you think?

10:01, 22 January 2015

Any example or use case that brings feature sets nearer to a user is welcome and appreciated. We have a new page called Use cases that is actually meant for this sort of purpose. You might want to describe your scenario in two or three sentences and link to the resource that contains your use case.

10:26, 22 January 2015

Thank you, the use cases are very helpful! They give general ideas about what kind of wikis are in use for what kind of purposes. What I was thinking of was more concrete examples of specific features, so links to specific pages in wikis where the features are used, not to wiki main pages (unless the features are used on the main pages). What I saw now is that I am at the wrong page here anyways because we don't set values like described on this help page here but with features of the forms extension, and how this works is described on the help pages of that extension. I now asked there. Sorry for the confusion.

17:32, 24 January 2015

parser in #set

Dear friends! I use SMW in my origami wiki. In version SMW 1.5 and SemanticResultFormats 1.5 I can use Wiki syntax with parser in #set

property for model - text. See here property on russian (описание модели)

01 smf.jpg

On page in gallery caption I get wiki text

03 smf.jpg

After update to version SMW 1.7.1 and SemanticResultFormats 1.7.1 now property model is empty.

02 smf.jpg

Can you help me, how I can use parser and wiki syntax in my property for caption.


10:09, 6 January 2013

This is the code that sets the property:

{{#set:Описание модели={{{!}} class="oritable" width="100%"
 {{!}}{{#if:{{{шагов|}}}|({{{шагов|}}})|}} ''{{{название модели|}}}'' {{#if:{{{opus|}}}|(op.{{{opus|}}}{{#if:{{{ver_opus|}}}| v.{{{ver_opus|}}}|}}{{#if:{{{num_opus|}}}|-{{{num_opus|}}}|}})|}} {{#if: {{{konkurs|}}}|([[{{{konkurs|}}}{{!}}{{{num_tur|}}} тур]])|}}
 {{!}}{{#if:{{{источник|}}}|[[{{{источник|}}}]]|~ ~ ~}} {{#if:{{{страница|}}}|(стр.{{{страница|}}})}}
 {{!}} & ({{#arraymap:{{{источники|}}}|,|x|[[x]]}})}}
 {{!}}({{{addtomodel|}}}{{#if:{{{formattomodel|}}}| + {{{formattomodel|}}}}})|}}

It is called from within a template hence the named parametres.

This wikicode is almost undebuggable. Sir, I can only suggest:

  • copy it into a separate template, check its calls with different combinations of empty and non-empty parametres, and comment out fragments of the template (using binary search) until the source of trouble is found;
  • replace wiki markup for the table with pure HTML;
  • upgrade to the last stable versions of MW and SMW.
17:10, 6 January 2013

Thanks for reply!

1. First, I am upgrade wiki to v.1.20 and SMW to 1.8. - my query not displayed. Now I use on local SMF 1.7.1

2. Yes, I did it. And find problem with parser

{{#set:Описание модели= ''{{{название модели|}}}'' }} - work is good

{{#set:Описание модели= {{#if:{{{var|}}}|({{{var|}}})|}} ''{{{название модели|}}}'' }} - not worked. Property is empty.

If you have SMW > 1.7 - Can you check it out with parser function {{#if:{{{var|}}}|({{{var|}}})|}}


17:30, 6 January 2013

If {{{название модели|}}} is empty, the apostrophes are interpreted as ''' ' and therefore unbalanced. Try replacing them with <em>. Not that I hope it would help (in a wiki I checked it in, the property was set anyway).

You could also try to replace emptyness in the else branch of the {{#if:}} call with a space or, better, <nowiki></nowiki>. {{#set:}} might break on empty substrings.

Worst of all, {{#set:}} may be called before {{#if:}}, not after as expected.

17:55, 6 January 2013

Видно, мне это не по силам сообразить. Перепробовал массу вариантов, и последовательно обновлял вики и SMF. Не сочтите за наглость - обратился к вам за помощью через http://www.formspring.me.

Попробую еще убрать апострофы.

18:19, 6 January 2013
Edited by author.
Last edit: 00:16, 7 January 2013

Anyway, look here. It works. So I recommend to upgrade anyway (don't forget to run the upgrade scripts for MW and SMW).

18:21, 6 January 2013

Действительно, работает. Большое спасибо. Я обновляю как раз-таки через web-интерфейс. Видимо в этом и кроется пробема. А по другому у меня не получится - я делаю все на локалке (windows). Или можно как-то по другому обновить (руководство по обновлению читал)

18:36, 6 January 2013

Тогда учтите, что семантические данные обновляются не мгновенно, а посредством рабочих заданий, что может привести ко временному отсутствию результатов в запросах SMW, пока данные не перегенерируются. Кстати, недавно в этой вики обсуждался вопрос (ссылки не могу найти) обновления, когда доступен только веб-интерфейс. Кажется, написали даже страницу справки. У кого-то тоже были затруднения.

Вообще, для полноценного администрирования вики его недостаточно. Подумайте об организации доступа через удалённый рабочий стол или по telnet.

18:45, 6 January 2013

You also should make sure that, after the upgrade, SMW still understands that Описание модели is still of Text type. Merry Christmas.

17:25, 6 January 2013

Yes, of course - I do it again the property to text. I also have tried other properties - still empty.

Marry Christmas too!

17:35, 6 January 2013