Reputation: 31
I have the following construction in the template to check whether attributes are full
{{#if:{{{typeip|}}}|'''Type IP:'''{{{typeip}}}|<big>'''Type IP:'''</big><span style="color: red">not filled in</span>}}
I want the typyap attribute to be a property so that I can find it by semantic search or by using a query via the #ask function.
I tried the following construction
{{#if:[[typeip::{{{typeip|}}}]]|'''Type IP:'''{{{typeip}}}|<big>'''Type IP:'''</big><span style="color: red">not filled in</span>}}
But it doesn't work. The #asc function returns an empty request and the type ip property page is empty. Can you tell me what I'm doing wrong? I performed reindexing using a service script rebuildData.php But that doesn't help either. I tried to insert the property in various other places in the template, but it doesn't work either. The template is filled in using the form.
Thank you in advance!
Upvotes: 1
Views: 502
Reputation: 4539
Of course, it doesn't work. You invoke the {{#if:}}
parser function incorrectly.
Its parametres are:
Therefore the semantic annotation should be in the second parametre, not the first:
{{#if:{{{typeip|}}}
| '''Type IP:''' [[typeip::{{{typeip}}}]]
| <big>'''Type IP:'''</big><span style="color: red">not filled in</span>
}}
{{{typeip}}}
should be bare text without any wiki formatting. If you must pass wikitext to it to convert wikilinks into semantic annotations setting properties of the type Page, the simplest way will be as follows:
Module:Inject
with the following content:return {
property = function (frame)
local wikitext, property = frame.args[1], frame.args[2]
local annotation = mw.ustring.gsub (
wikitext,
'%[%[([^|%]]+)(|[^%]]*)?%]%]',
'[[' .. property .. '::%1%2]]'
)
return annotation
end
}
{{#invoke:Inject|property|{{{typeip|}}}|typeip}}
The template will convert any wikilinks in {{{typeip}}}
like [[A]]
or [[B|C]]
into semantic annotations like [[typeip::A]]
or [[typeip::B|C]]
.
Upvotes: 1