<p>You can use the <a href="https://craftcms.com/docs/3.x/dev/tags.html#dd" rel="nofollow noreferrer">dd tag</a> to dump the contents of a variable and exit the current request. This will allow you to see the type and contents of a variable:</p>
<pre class="lang-twig prettyprint-override"><code>{% dd entry %}
</code></pre>
<p>If the variable you're inspecting is an object, this will also show you its type. Once you know the type of the variable, you can look it up in the <a href="https://docs.craftcms.com/api/v3/" rel="nofollow noreferrer">API reference</a> to see what properties and methods are available on it. For example, the <code>entry</code> variable in entry templates is a <a href="https://docs.craftcms.com/api/v3/craft-elements-entry.html" rel="nofollow noreferrer"><code>craft\elements\Entry</code> object</a>. Of course, the API documentation doesn't know about the custom fields you have on your entries.</p>
<p>If you want to list <em>all</em> variables available in the current context of a template, you can use the special <code>_context</code> variable. This array contains all variables for the current context, the array keys being the variable names. You can dump them like this:</p>
<pre class="lang-twig prettyprint-override"><code>{% dd _context %}
</code></pre>
<p>This will result in a long list. A useful trick is to only dump the variable names using the <a href="https://twig.symfony.com/doc/2.x/filters/keys.html" rel="nofollow noreferrer"><code>keys</code> filter</a>:</p>
<pre class="lang-twig prettyprint-override"><code>{% dd _context | keys %}
</code></pre>
<p>This will dump a list of variable names. This list includes the <a href="https://craftcms.com/docs/3.x/dev/global-variables.html" rel="nofollow noreferrer">global variables provided by Craft</a>, some variables depending on the current route (like the <code>entry</code> variable on entry routes), as well as any variables provided by plugins or modules or defined by you in the template itself.</p>
<p>As you mentioned, you can also use the <a href="https://plugins.craftcms.com/kint" rel="nofollow noreferrer">Kint plugin</a> to use the dump methods provided by it, which is a bit nicer and easier to navigation than the <code>dd</code> output.</p>
<hr />
<h2>Update regarding question clarifications</h2>
<p>If you're looking for a place where you can find every available property, method, field, attribute, etc for every component – that's just the <a href="https://docs.craftcms.com/api/v3/" rel="nofollow noreferrer">API reference</a>. Custom fields won't show up in the API reference since they're specific to a site.</p>
<blockquote>
<p>Let's say that I'm starting with a clean / empty template and want to know which variables are available to use in the actual template.</p>
</blockquote>
<p>Based on the current, a variable with the current element (for example, the current <code>entry</code> will be available in your template). That is the gateway to most properties and fields you're gonna need. Pre-defined properties (like the URL, slug, title, ID) can be found in the API documentation for the <a href="https://docs.craftcms.com/api/v3/craft-elements-entry.html" rel="nofollow noreferrer"><code>Entry</code> model</a>. Besides that, you can access any custom field available on the entry. You can find the handles for those in a number of ways:</p>
<ul>
<li>Through Settings -&gt; Sections, look up the section and then the entry type your entry belongs to.</li>
<li>In your user profile, check the checkbox <em>Show field handles in edit forms</em> to display the machine names of all fields in the edit form for the entry.</li>
<li>A handy one-liner to display a list of custom fields on any element:</li>
</ul>
<pre class="lang-twig prettyprint-override"><code>{% dd entry.getFieldLayout().getFields()|column('handle') %}
</code></pre>
<p>Some fields will contain queries to get related assets. For example, any asset field will return an <a href="https://docs.craftcms.com/api/v3/craft-elements-db-assetquery.html" rel="nofollow noreferrer">AssetQuery</a> that you can use to fetch the related asset. Make sure to read the documentation on <a href="https://craftcms.com/docs/3.x/element-queries.html" rel="nofollow noreferrer">Element Queries</a> to find out more.</p>
<p>Once you have the related asset (in this case, the product image), you can use <code>dd</code> to find the class name to look up in the API reference. In this case, you're looking for <a href="https://docs.craftcms.com/api/v3/craft-elements-asset.html" rel="nofollow noreferrer">craft\elements\Asset</a> where the <a href="https://docs.craftcms.com/api/v3/craft-elements-asset.html#method-geturl" rel="nofollow noreferrer">getUrl method</a> is documented.</p>

CC BY-SA 4.0
2021-12-27T16:21:28.903Z
2022-01-05T16:28:45.610Z
2022-01-05T16:28:45.610Z
MoritzLost
<p>As I'm still a total n00b in working with CraftCMS, so I hope to get some help from more experienced users :-)</p>
<p>I followed every available tutorial (which are very clear and well written. Great job!) but of course there's still enough to explore and discover. The hardest part for me is to find the correct variables and the format to use in templates. That's what this topic is about ..</p>
<p>I've worked with Lightspeed HQ for some years, which is also a twig / symfony based platform. What made templating very easy in Lightspeed HQ is it's developer toolbar that shows all available variables in a wink. Here's an example of the toolbar, active on a product-page.</p>
<p><a href="https://i.sstatic.net/9cGM0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9cGM0.png" alt="enter image description here" /></a></p>
<p>When I need to show prices for example, I simply can use this syntax:</p>
<pre><code>{{ product.price.price }}

// or when I need price incl. and excl. taxes
&lt;p&gt;Price incl. TAX: {{ product.price.price_incl }}&lt;/p&gt;
&lt;p&gt;Price excl. TAX: {{ product.price.price_excl }}&lt;/p&gt;
</code></pre>
<p>[ADDED]
I'd like to see (if possible) a dump of all variables available in the backend, and more important, the way they need to get called eventually. Maybe some example would explain it better:</p>
<p>Let's say that I'm starting with a clean / empty template and want to know which variables are available to use in the actual template. I have a slider, which should be dynamic. In that slider I need to call / show specific related product properties. In this case it should be the featured product image. I'm totally stuck in finding the right variable to call: i.e. {{ variableimageentry.getUrl }} for the source.</p>
<p>In the above example I constructed it this way:
<a href="https://i.sstatic.net/Zi8zK.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Zi8zK.png" alt="enter image description here" /></a></p>
<p>I was hoping that there was a way to create an overview of all fields' variables, ready to use in templates.</p>
<p>I came by the KINT plugin, but can't find a usable way to get something similar as my example. Maybe I'm overlooking something, so I hope someone could help me out here.</p>
<p>Thank you very much in advance for your help and thinking with me!</p>

CC BY-SA 4.0
2022-01-01T12:05:53.123Z
Thank you very much @MoritzLost for your explanation! Maybe I'm totally wrong here, but in this case all 'objects' are returned when they are **already** declared and working in the active template, right? That's actually not what I'm after. I'd like to see a dump of all variables available in the backend, and more important, the way they need to get called eventually. Maybe some example would explain it better: Let's say that I'm starting with a clean / empty template and want to know which variables are available to use in the actual template. I have a slider, which should be dynamic. In tha
Hielke
CC BY-SA 4.0
2022-01-05T16:29:19.250Z
I've updated my answer with some tips for your situation.
MoritzLost
<craft3><templating><environmentvariables>
Is there a way to return all available (custom) variables in some kind of list?
# Is there a way to return all available (custom) variables in some kind of list?

(Asked by: username_0 on 2021-12-27)

As I'm still a total n00b in working with CraftCMS, so I hope to get some help from more experienced users :-)
I followed every available tutorial (which are very clear and well written. Great job!) but of course there's still enough to explore and discover. The hardest part for me is to find the correct variables and the format to use in templates. That's what this topic is about ..
I've worked with Lightspeed HQ for some years, which is also a twig / symfony based platform. What made templating very easy in Lightspeed HQ is it's developer toolbar that shows all available variables in a wink. Here's an example of the toolbar, active on a product-page.

When I need to show prices for example, I simply can use this syntax:
{{ product.price.price }}

// or when I need price incl. and excl. taxes
Price incl. TAX: {{ product.price.price_incl }}
Price excl. TAX: {{ product.price.price_excl }}

[ADDED]
I'd like to see (if possible) a dump of all variables available in the backend, and more important, the way they need to get called eventually. Maybe some example would explain it better:
Let's say that I'm starting with a clean / empty template and want to know which variables are available to use in the actual template. I have a slider, which should be dynamic. In that slider I need to call / show specific related product properties. In this case it should be the featured product image. I'm totally stuck in finding the right variable to call: i.e. {{ variableimageentry.getUrl }} for the source.
In the above example I constructed it this way:

I was hoping that there was a way to create an overview of all fields' variables, ready to use in templates.
I came by the KINT plugin, but can't find a usable way to get something similar as my example. Maybe I'm overlooking something, so I hope someone could help me out here.
Thank you very much in advance for your help and thinking with me!

**Tags:** craft3, templating, environmentvariables
> **Comments:**
> **username_0**: Thank you very much @MoritzLost for your explanation! Maybe I'm totally wrong here, but in this case all 'objects' are returned when they are **already** declared and working in the active template, right? That's actually not what I'm after. I'd like to see a dump of all variables available in the backend, and more important, the way they need to get called eventually. Maybe some example would explain it better: Let's say that I'm starting with a clean / empty template and want to know which variables are available to use in the actual template. I have a slider, which should be dynamic. In tha  
> **username_1**: I've updated my answer with some tips for your situation.  

---

## 1 answers

### Answer by username_1 on 2021-12-27. Score: 2

You can use the dd tag to dump the contents of a variable and exit the current request. This will allow you to see the type and contents of a variable:
{% dd entry %}

If the variable you're inspecting is an object, this will also show you its type. Once you know the type of the variable, you can look it up in the API reference to see what properties and methods are available on it. For example, the entry variable in entry templates is a craft\elements\Entry object. Of course, the API documentation doesn't know about the custom fields you have on your entries.
If you want to list all variables available in the current context of a template, you can use the special _context variable. This array contains all variables for the current context, the array keys being the variable names. You can dump them like this:
{% dd _context %}

This will result in a long list. A useful trick is to only dump the variable names using the keys filter:
{% dd _context | keys %}

This will dump a list of variable names. This list includes the global variables provided by Craft, some variables depending on the current route (like the entry variable on entry routes), as well as any variables provided by plugins or modules or defined by you in the template itself.
As you mentioned, you can also use the Kint plugin to use the dump methods provided by it, which is a bit nicer and easier to navigation than the dd output.

Update regarding question clarifications
If you're looking for a place where you can find every available property, method, field, attribute, etc for every component – that's just the API reference. Custom fields won't show up in the API reference since they're specific to a site.

Let's say that I'm starting with a clean / empty template and want to know which variables are available to use in the actual template.

Based on the current, a variable with the current element (for example, the current entry will be available in your template). That is the gateway to most properties and fields you're gonna need. Pre-defined properties (like the URL, slug, title, ID) can be found in the API documentation for the Entry model. Besides that, you can access any custom field available on the entry. You can find the handles for those in a number of ways:

Through Settings -> Sections, look up the section and then the entry type your entry belongs to.
In your user profile, check the checkbox Show field handles in edit forms to display the machine names of all fields in the edit form for the entry.
A handy one-liner to display a list of custom fields on any element:

{% dd entry.getFieldLayout().getFields()|column('handle') %}

Some fields will contain queries to get related assets. For example, any asset field will return an AssetQuery that you can use to fetch the related asset. Make sure to read the documentation on Element Queries to find out more.
Once you have the related asset (in this case, the product image), you can use dd to find the class name to look up in the API reference. In this case, you're looking for craft\elements\Asset where the getUrl method is documented.


---

