I need to insert project variable into map composer file (.qpt) for showing specific legend item. The item is a layer constructed from a URL query that I need to dynamically change based on a project variable.
When I open another project, the layer URL query in the legend has a fixed value and the legend does not display the symbol, only the layer title, because in that project the layer has a URL query with a dynamic variable and the legend does not "find" the corresponding layer in the project.
...<layer-tree-layer name="Some Name" id="query_where_obec_3D598259_text__objectIds__time__geometry__geometryType_...">
<customproperties>
<Option type="Map">
<Option name="cached_name" type="QString" value="Území obce"/>
</Option>
</customproperties>
</layer-tree-layer>
<custom-order enabled="0"/>
</layer-tree-group>...
In the "ID" option i need to insert the QGIS variable.
Is this possible or is there another solution for this problem?
EDIT: I must have auto update turned off for custom legend item settings.
REPRODUCIBLE EXAMPLE: Create a label in map composer, save as template (.qpt) and insert a qgis variable in the .qpt file somehow and after opening the template in a new map composer it should appear in the label.
Best Answer
The correct syntax is
labelText="[% @myvar %]"
: