query-d404c00394fd99ce5ca750308e3e179f

rq turtle/ttl

Subquery headache - article workshop pages for Wiki Loves Living Heritage. Wiki Loves Living Heritage/Intangible Cultural Heritage of Finland/ArticlesI am finding out if article workshop pages could easily be created for lists in the project or other custom lists of topics. The workshop page would be more or less similar to the translation tables but they could be further customized. I have created the test page here: or the hardcoded buttons on the test page. Wiki Loves Living Heritage/JoulupukkiI am now figuring out how to produce the buttons for articles. They would behave similarly to the buttons on a topic page, see for example here: The difference to the topic page is that this list will receive a custom list of language codes as user input through a template that I have not yet created. Query 1 retrieves the list of items

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?item ?qid (GROUP_CONCAT (DISTINCT ?ich; separator= ",") AS ?ichid) (GROUP_CONCAT (DISTINCT ?inventory; separator= ",") AS ?inventories) (GROUP_CONCAT (DISTINCT ?type; separator= ",") AS ?types) (GROUP_CONCAT(DISTINCT ?region; SEPARATOR = ",") AS ?regions) (SAMPLE(?image) AS ?image)  WHERE {
  {
    { ?item wdt:P6104 wd:Q112898263. }
  UNION
    { ?item wdt:P3259 ?ichstatus. }
  }
  ?item wdt:P17|wdt:P495|wdt:P183|wdt:P2596|wdt:P3259/wdt:P17|wdt:P2541|wdt:P2341 wd:Q33 .
  MINUS { ?item (wdt:P31/wdt:P279*) wd:Q116056897. }
  MINUS { ?item wdt:P31 wd:Q13406463 . }
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  OPTIONAL { ?item wdt:P17|wdt:P495|wdt:P183|wdt:P2596|wdt:P3259/wdt:P17|wdt:P2541|wdt:P2341 ?reg. }
  OPTIONAL { ?item wdt:P10221 ?ich. }
  BIND(SUBSTR(STR(?reg), 32 ) AS ?region)
  OPTIONAL { ?item wdt:P18 ?img. 
      BIND(CONCAT('File:',wikibase:decodeUri(SUBSTR(STR(?img), 52))) AS ?image)
  }
  OPTIONAL { ?item wdt:P31 ?P31. 
      BIND(SUBSTR(STR(?P31), 32) AS ?type)
  }
  OPTIONAL { ?item wdt:P3259 ?inv.
      BIND(SUBSTR(STR(?inv), 32) AS ?inventory)
  }
}
GROUP BY ?item ?qid
ORDER BY DESC (?image)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?P31") v6("?ich"):::projected v13("?ichid") v3("?ichstatus") v17("?image"):::projected v8("?img") v11("?inv") v14("?inventories") v12("?inventory"):::projected v2("?item"):::projected v4("?qid"):::projected v5("?reg") v7("?region"):::projected v16("?regions") v10("?type"):::projected v15("?types") a1((" ")) a2((" ")) a3((" ")) c13(["wd:Q116056897"]):::iri c2(["wd:Q112898263"]):::iri c5(["wd:Q33"]):::iri c14(["wd:Q13406463"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P3259"--> v3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P6104"--> c2 end union0r <== or ==> union0l end subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; subgraph union4[" Union "] subgraph union4l[" "] style union4l fill:#abf,stroke-dasharray: 3 3; subgraph union5[" Union "] subgraph union5l[" "] style union5l fill:#abf,stroke-dasharray: 3 3; subgraph union6[" Union "] subgraph union6l[" "] style union6l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P2341"--> c5 end subgraph union6r[" "] style union6r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P2541"--> c5 end union6r <== or ==> union6l end end subgraph union5r[" "] style union5r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P3259"--> a1 a1 --"wdt:P17"--> c5 end union5r <== or ==> union5l end end subgraph union4r[" "] style union4r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P2596"--> c5 end union4r <== or ==> union4l end end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P183"--> c5 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P495"--> c5 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P17"--> c5 end union1r <== or ==> union1l end subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c13 end subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> c14 end bind2[/"substring(str(?item),'32^^xsd:integer')"/] v2 --o bind2 bind2 --as--o v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; subgraph union7[" Union "] subgraph union7l[" "] style union7l fill:#abf,stroke-dasharray: 3 3; subgraph union8[" Union "] subgraph union8l[" "] style union8l fill:#abf,stroke-dasharray: 3 3; subgraph union9[" Union "] subgraph union9l[" "] style union9l fill:#abf,stroke-dasharray: 3 3; subgraph union10[" Union "] subgraph union10l[" "] style union10l fill:#abf,stroke-dasharray: 3 3; subgraph union11[" Union "] subgraph union11l[" "] style union11l fill:#abf,stroke-dasharray: 3 3; subgraph union12[" Union "] subgraph union12l[" "] style union12l fill:#abf,stroke-dasharray: 3 3; v2 -."wdt:P2341".-> v5 end subgraph union12r[" "] style union12r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P2541"--> v5 end union12r <== or ==> union12l end end subgraph union11r[" "] style union11r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P3259"--> a3 a3 --"wdt:P17"--> v5 end union11r <== or ==> union11l end end subgraph union10r[" "] style union10r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P2596"--> v5 end union10r <== or ==> union10l end end subgraph union9r[" "] style union9r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P183"--> v5 end union9r <== or ==> union9l end end subgraph union8r[" "] style union8r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P495"--> v5 end union8r <== or ==> union8l end end subgraph union7r[" "] style union7r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P17"--> v5 end union7r <== or ==> union7l end end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P10221".-> v6 end bind3[/"substring(str(?reg),'32^^xsd:integer')"/] v5 --o bind3 bind3 --as--o v7 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P18".-> v8 bind4[/"concat('File:',http://wikiba.se/ontology#decodeUri(substring(str(?img),'52^^xsd:integer')))"/] v8 --o bind4 bind4 --as--o v17 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P31".-> v9 bind5[/"substring(str(?P31),'32^^xsd:integer')"/] v9 --o bind5 bind5 --as--o v10 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P3259".-> v11 bind6[/"substring(str(?inv),'32^^xsd:integer')"/] v11 --o bind6 bind6 --as--o v12 end bind12[/"?ich"/] v6 --o bind12 bind12 --as--o v13 bind13[/"?inventory"/] v12 --o bind13 bind13 --as--o v14 bind14[/"?type"/] v10 --o bind14 bind14 --as--o v15 bind15[/"?region"/] v7 --o bind15 bind15 --as--o v16 bind16[/"sample(?image)"/] v17 --o bind16 bind16 --as--o v17