<p>Please have a look at the "Template Variables" section of the documentation:
<a href="http://buildwithcraft.com/docs/plugins/variables" rel="nofollow">http://buildwithcraft.com/docs/plugins/variables</a></p>

<p>The template variables are the containers of data which you can access from your twig templates using <code>craft.yourPluginName.yourPluginVariableFunctionName</code></p>

<p>Let's say you want to loop through 3 different items in an array from your Plugin. Your Plugin variables file might look like this:</p>

<pre><code>&lt;?php
namespace Craft;

class PluginNameVariable
{
    public function data()
    {
        return array('one', 'two', 'three');
    }
}
</code></pre>

<p>In your template you can now "fetch" this data like this - in a loop:</p>

<pre><code>{% for item in craft.pluginName.data %}
    {{ item }}
{% endfor %}
</code></pre>

<p><em>Please not this code is not tested</em></p>

CC BY-SA 3.0
2014-10-27T20:43:00.047Z
2015-04-07T03:48:06.580Z
2015-04-07T03:48:06.580Z
naboovalley
<p>I am looking to develop a plugin which out put the data in a loop Or that plugin would populate the array data with template tag. Could anyone please help me or share a doc link.﻿</p>

<p>Thanks,</p>

<plugin-development>
Develop a plugin for outputting data in a loop
# Develop a plugin for outputting data in a loop

(Asked by: username_0 on 2014-10-27)

I am looking to develop a plugin which out put the data in a loop Or that plugin would populate the array data with template tag. Could anyone please help me or share a doc link.﻿

Thanks,

**Tags:** plugin-development

---

## 1 answers

### Answer by username_1 on 2014-10-27. Score: 7 | Accepted answer

Please have a look at the "Template Variables" section of the documentation:
http://buildwithcraft.com/docs/plugins/variables
The template variables are the containers of data which you can access from your twig templates using craft.yourPluginName.yourPluginVariableFunctionName
Let's say you want to loop through 3 different items in an array from your Plugin. Your Plugin variables file might look like this:

In your template you can now "fetch" this data like this - in a loop:
{% for item in craft.pluginName.data %}
    {{ item }}
{% endfor %}

Please not this code is not tested


---

