Using Statamic Partial Variables within Entries Tags?

1.2k views Asked by At

Trying to use partials in the Statamic CMS to keep some content areas as DRY as possible.

According to the documentation, I can pass variables to a partial like so:

{{ theme:partial src="sidebar" my_count="2" }}

In my partials/sidebar template, I have the following:

{{ my_count }}

{{ entries:listing folder="projects" }}
  I am number {{ my_count }}
{{ /entries:listing }}

However, when the page loads, the variable inside the {{ entries:listing }} tag is not parsed.

2
I am number
I am number
I am number
I am number
I am number

Am I missing a step to get {{ my_count }} to output when called inside the entries tag pair?

NOTE: My ultimate goal is to pass the variable to a parameter, like so:

{{ entries:listing folder="projects" limit="{{ my_count }}" }}
  ...
{{ /entries:listing }}
1

There are 1 answers

0
Curtis Blackwell On BEST ANSWER

The variable won't parse inside of the entries:listing tag pair, but you can use it as a parameter.

This example code works:

partials/temp.html

{{ entries:listing
    folder = "blog"
    limit  = "{ limit }"
}}

  {{ title }}

{{ /entries:listing }}

templates/temp.html

{{ theme:partial src="temp" limit="2" }}