Modèle:PDR

De Semantic MediaWiki - Sandbox

This is a modified part of the template webpage I am trying to create (not everything is here, but it allows us to recreate the issue I am facing with).
You can see an example here: ZZ999. In this example, here's what the user will specify:

{{PDR
 |Nombre_Points=
 |Point1=
 |Point2=
 |Point3=
 |Nombre_Troncons=
 |Troncon1_Secteur=
 |Troncon1_Debut=
 |Troncon1_Fin=
}}

Not clear enough? Please feel free to ask for any precision! :)

Remark

Seems not working here, it looks like the Variables Extension has not been associated to the sandbox? None of my #var can be evaluated.

Step 1

  • First, I begin a while loop (using "i", the loop itself is not represented in here to enlight the code).
  • In this loop, "i" goes from 1 to Nombre_Points specified by the user in the template, and one variable is created for each Point specified by the user.
  • Each variable takes what the user gives to the template, and says that this given data is a Point property (which has Text type, see here: Attribut:Point).
  • For instance, with ZZ999, "i" will go from 1 to 3 (the user specifies 3 different Point within the template), and in the loop for each value of "i" you will have:
{{ #vardefine: Point{{ #var: i }}| [[Point::{{{ Point{{ #var: i }}| }}} ]] }}
{{ #vardefine: i| {{ #expr: {{ #var: i }} + 1 }} }}







Step 2

  • Then, another while loop is created, not included in the first one (let's use "j" so we make the difference between the two of them).
  • "j" goes from 1 to Nombre_Troncons the user has specified within the template.
  • Nombre_Troncons is not related to Nombre_Points.
  • I decide then to define a few useful var which will help me to enlight the code (so I don't manipulate too many {{ #var: j }} etc).
  • Another variable Troncon_Temp is also created inside this loop (it's a local variable), and will be completed in another loop, included in the "j" loop (here Troncon_Temp is only initiated).
  • Debut and Fin are numbers specified by the user, they tell which Point starts a Troncon (it means Section in French FYI, I will translate everything later if it can help of course) and which Point ends it. For instance, if Point2 begin a Troncon, user will have to write Troncon1_Debut=2:
{{ #vardefine: Debut | {{{ Troncon{{ #var: j }}_Debut| }}} }}
{{ #vardefine: Fin | {{{ Troncon{{ #var: j }}_Fin| }}} }}
{{ #vardefine: Secteur | {{{ Troncon{{ #var: j }}_Secteur| }}} }}
{{ #vardefine: Troncon_Temp | {{ #var: Point{{ #var: Debut}} }} }}




Step 3

  • I begin another while loop (using "j_bis"), included in the first "j" loop.
  • "j_bis" goes from Debut to Fin.
  • Troncon_Temp is here being updated in this second loop whenever "j_bis" is incremented (another Point is being added to Troncon_Temp):
{{ #vardefine: Troncon_Temp | {{ #var: Troncon_Temp }} - {{ #var: Point{{ #var: j_bis }} }} }}



Step 4

Then, this is where it does not work: SMW doesn't understand when I am telling it to set a global variable, which value is the data within Troncon_Temp:

{{ #set: 
 |Troncon_{{ #var: Secteur }} = {{ #var: Troncon_Temp }} 
}}

RMK : Troncon_S has been defined as being of Text Type, see here: Attribut:Troncon_S.



Step 5

Because of the step before, I can't see the result of course.

Result of the show request:

{{ #show: {{PAGENAME}} | ?Troncon_{{ #var: Secteur }} }}

Result of the show request:

Les cookies nous aident à fournir nos services. En utilisant nos services, vous acceptez notre utilisation de cookies.