Access URL parameter within Fetch Statement
-
Hi there, I’m struggling to access a parameter in the query, set this value and then use it in the fetch condition. I have followed the forums but am still stuck
I’m wanting to navigate to https://ads.adon.co.nz/?deviceid=Test which will send the parameter deviceid with the value of Test to the page with the following fetch/twig statement (note if I dont use the parameter and just hardcore the value of Test the codes runs)
{% set devicename = query.params[‘deviceid’] %}
{% fetchxml collection=”customers” cache=”PT30M” %}
<fetch mapping=’logical’ returntotalrecordcount=’true’>
<entity name=”cr152_ad”>
<attribute name=”cr152_adid” />
<attribute name=”cr152_name” />
<attribute name=”cr152_width” />
<attribute name=”cr152_imageurl” />
<attribute name=”cr152_height” />
<attribute name=”cr152_adqueue” />
<attribute name=”cr152_account” />
<order attribute=”cr152_name” descending=”false” />
<filter type=”and”>
<condition attribute=”statecode” operator=”eq” value=”0″ />
</filter>
<link-entity name=”cr152_adqueue” from=”cr152_adqueueid” to=”cr152_adqueue” link-type=”inner” alias=”ae”>
<link-entity name=”cr152_device” from=”cr152_adqueue” to=”cr152_adqueueid” link-type=”inner” alias=”af”>
<filter type=”and”>
<condition attribute=”cr152_name” operator=”eq” value=”{{ devicename }}” />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>
{% endfetchxml %}
{% if customers.results.entities|length > 0 %}-
{% for customer in customers.results.entities %}
- {{customer[“cr152_name”]}}
{% endfor %}
{% else %}
No ads found.{% endif %}
I’m using the Dataverse Gutenberg block
- The topic ‘Access URL parameter within Fetch Statement’ is closed to new replies.