0

(I'm kind of new to the whole Semantic Mediawiki thing and have been scouring the web for some leads on this small project I'm doing. )

How do I go about defining properties that are derived from other properties in a Semantic Mediawiki. Assuming I have created course with SMW and would to provide details on the progress of the course (i.e. the current page / total number of pages in %).

I read there is this Semantic Extra Special Properties extension where an extra SUBPAGES property exist. Would it help? I'm guessing I could go about with #ask or some sorts and check on what subpage I am of the whole course?

Any further (better) ideas?

Jon Gan
  • 867
  • 1
  • 11
  • 22

1 Answers1

0

You can define a Semantic Property using an #ask query. Here is an example in one of my wikis doing just what you described, showing a count and then a percentage of the total population. In this case I'm defining two variables first just to make the code more readable and since I need the website_count value twice I avoid a 2nd query.

{{
#vardefine: website_extension |
  {{#ask: [[Has extension::{{FULLPAGENAME}}]] | format=count }}
}}{{
#vardefine: website_count |
  {{#ask: [[Category:Website]] [[Is validated::True]] [[Is active::True]] [[Collect extension data::True]] | format=count }}
}}
[[Has website count::{{#var:website_extension}}]] ([[Has website percent::{{#expr: ( ( {{#var: website_extension}} / {{#var: website_count}} ) * 100 ) round2 }}]]%)

Subobjects and the Semantic Extra Special Properties are not needed for any of this.

  • Hi Jamie thanks for the help! However in your case, you're not actually counting the order in which your website is place if I interpreted the code correctly? Is there any way to determine the position of a wiki page in, say, a group of pages possessing particular properties, sorted by a particular user-defined index? I'm guessing it's not too difficult to "group" pages together but to define a unique index for each page which then can be neatly changed without conflicts is the challenge.. or maybe I just don't know my way around Semantic MW. – Jon Gan May 08 '13 at 09:52
  • Sorry, I didn't realize you were looking for an order. It actually sounds like you are looking for a rank? This item is 15th out of 100? You could then derive your percentages. For this, just do a count like above but add a test for the order. For example `{{#ask: [[Has extension::{{FULLPAGENAME}}]] [[Has sorted field::>{{#var: some_value}}]] | format=count }}`. I actually do exactly this on [this template](http://wiki.planetkubb.com/w/index.php?title=Template:Team&action=edit), search for `Has team rank`. – Jamie Thingelstad May 16 '13 at 19:28