hno2
hno2

Reputation: 107

Collection of all template contents

in my media wiki for my organisation I want to create a List of all decisions made in the past with the corresponding result (Yes/No ..)

For this I created a new template, which highlights the decisions in our protocols and adds a Category with the decision question. (see the code below)

'''Decision:''' {{{Question}}}</br>
({{{Yes}}}/{{{No}}}/{{{abstention}}}) [Yes/No/No vote]
{{#ifexpr: {{{Yes}}}>{{{No}}}|[[Decision::{{{Question}}}::Yes| ]]|[[Decision::{{{Question}}}::No| ]]}}

But when I use #ask to get all the questions.

{#ask: [[Decision::+]]
|?Decision
}}

I cannot get it to work correctly. I want to display a table where each row has the Question and it's corresponding result (Yes/No) in one column. My current status is having the Question followed by ::Yes or ::No like Do you like this question::Yes

My goal for the result is

__________________________________
|Do you like this question | Yes |
__________________________________

Many thanks for your help in advance, I feel like the solution is really close but I just can't get what I want...

Upvotes: 1

Views: 80

Answers (1)

IRA1777
IRA1777

Reputation: 613

Assuming that your template is instantiated only once per page (each question has its own page), you should separate semantic properties like:

'''Decision:''' {{{Question}}}

({{{Yes}}}/{{{No}}}/{{{abstention}}}) [Yes/No/No vote]

{{#set:Has question={{{Question}}}|Has decision={{#ifexpr: {{{Yes}}}>{{{No}}}|Yes|No}} }}

  • #set parser function creates properties silently, which is better than the piped inline syntax you used.
  • The whole point of semantic approach is to have... proper semantic. So here you have a question and a decision (yes or no), so the corresponding semantic properties should be Has question and Has decision.

Then the query will be:

{{#ask:[[Has question::+]]

|mainlabel=-

|?Has question

|?Has decision

|format=table

}}

If the starting assumption is not true (you have multiple template instances inside one page), you should turn to #subobject parser function to store your properties instead of #set, like this:

{{#subobject:

|Has question={{{Question}}}

|Has decision={{#ifexpr:{{{Yes}}}>{{{No}}}|Yes|No}}

}}

Query may remain the same.

Upvotes: 1

Related Questions