Using variables within a MySource_SET block - confirming design file code


(Douglas (@finnatic at @waikato)) #1

We have some code in our design files to generate the local section navigation, where we have a need to vary show_subs set to on_current or always.

Reading https://matrix.squiz.net/manuals/designs/chapters/design-tags#MySource-SET I’ve setup a variable declaration section earlier in the parse file:

>   <MySource_AREA id_name="menu_normal_showsubs" design_area="declared_vars" print="no"> 
>     <MySource_DECLARE name="level0" value="on_current" type="text" description="showsubs value for top level of local nav"/>
>     <MySource_DECLARE name="level1" value="on_current" type="text" description="showsubs value for first level of local nav"/>
>     <MySource_DECLARE name="level2" value="on_current" type="text" description="showsubs value for second level of local nav"/>
>     <MySource_DECLARE name="level3" value="on_current" type="text" description="showsubs value for third level of local nav"/>
>   </MySource_AREA>

and then have those output at the relevant levels e.g.

>     <MySource_SET name="show_subs" id_name="menu_normal_showsubs" var="level0" />
>     ...
>     <MySource_SET name="show_subs" id_name="menu_normal_showsubs" var="level1" />
>     ...
>     <MySource_SET name="show_subs" id_name="menu_normal_showsubs" var="level2" />
>     ...
>     <MySource_SET name="show_subs" id_name="menu_normal_showsubs" var="level3" />

And… it seems to be working.

Can anyone confirm this is a correct implementation for how variables are supposed to be used with a MySource_SET block?


(Bart Banda) #2

Didn’t know you could do that, which is cool I guess. I assume you are overwriting the value=“on_current” in your customisations?


(Douglas (@finnatic at @waikato)) #3

Yes. We’ve using a value of ‘always’ on some designs and this will help us have some flexibility between the old and new customisations we have.