How do I get data from a query datasource field in Sitecore using Scriban?

769 Views Asked by At

I have a query datasource field, and I want to access the data from within that field.

I have tried things like:

{{ for i_data in (sc_query i_page 'query:{{ i_page.NameOfField }}') }}
<h1>{{ i_data.Title }}</h1>
{{end}}

and

 <h1>{{ i_data.NameOfField.Title }}</h1>

For the first example, I have also tried 'query:'{{ i_page.NameOfField }}. I have copied and pasted the query to make sure it is valid, and it is. It works. Am I getting some syntax wrong, or is there another way of doing this?

0

There are 0 best solutions below