Using declared vars in design parse files


(gja) #1

Matrix Version: 5.4.5.1

I’m wondering if it is possible to access the value from a declared_vars design area within a design parse file.

For example:
<MySource_AREA id_name=“category_vars” design_area=“declared_vars” print=“no”>
<MySource_DECLARE name=“category” value="" type=“text” description=“Enter a category” />
</MySource_AREA>

then later in the parse file check if there is a value entered for the category variable and do something if the var isn’t empty.

I don’t want to set a metadata value as I don’t see the value in adding that to all the assets in a site just so we can have that value available in the design.

Any ideas?
Georgina.


(Luke Wright) #2

Hi Georgina,

I don’t think there’s a way to use the value of a declared_var in, for instance, a Show If design area - you’d need a condition that does that and I don’t believe there is a specific condition for that.

You are able to print out the value of a declared var using the MySource_PRINT tag:
<MySource_PRINT id_name="category_vars" var="category" />

That’s not particularly ideal for your scenario but it means you can have, say, JavaScript further down that interacts with the value of your declared variable.

You can also use it in MySource_SET tags later down in the file.