<p>In more recent versions of Craft 2.x (I forget when it was added), you can simply do this without needing a plugin:</p>

<pre><code>craft.config.get('setting', 'plugin')
</code></pre>

<p>Where <code>'plugin'</code> is the name of your plugin's config file (sans <code>.php</code>).</p>

<p>If you want to do this in Craft 3, you'd do:</p>

<pre><code>craft.app.getModule('pluginHandle').getSettings().mySetting
</code></pre>

CC BY-SA 3.0
2017-12-11T19:29:37.687Z
2017-12-11T19:29:37.687Z
Brad Bell
<p>From what I understand the only way to get plugin info back (in a template) is by doing:</p>

<pre><code>{% set plugin = craft.plugins.getPlugin('PluginHandle') %}
</code></pre>

<p>This returns an instance of <code>PluginVariable</code> for your plugin, so you have access to any method detailed in <code>craft/app/variables/PluginVariable.php</code> (<a href="http://buildwithcraft.com/classreference/variables/PluginVariable" rel="nofollow">the craft class reference</a>)</p>

<p>It looks like the <code>getSettings()</code> function isn't exposed in this, so I don't think its possible.</p>

<p>I could be wrong and there could be a way, but I couldn't figure it out from a quick look over the code :/</p>

CC BY-SA 3.0
2015-09-03T08:50:52.653Z
Thanks Alec - that's as far as I'd got with looking around, so good to have it confirmed!
Phil Gyford
CC BY-SA 3.0
2015-09-02T22:04:57.580Z
2015-09-02T22:04:57.580Z
Alec Ritson
<p>Not sure if there's a build in way, but you can set up a <a href="http://buildwithcraft.com/docs/plugins/variables" rel="nofollow">template variable</a> that returns the settings model.</p>

<pre><code>class MyPluginVariable
{
    public function settings()
    {
        return craft()-&gt;plugins-&gt;getPlugin('myPlugin')-&gt;getSettings();
    }
}
</code></pre>

<p>Then access it in your template.</p>

<pre><code>{% set settings = craft.myPlugin.settings %}
</code></pre>

CC BY-SA 3.0
2015-09-03T08:51:32.173Z
Thanks Carl. Looks like that's the closest I'm going to get.
Phil Gyford
CC BY-SA 3.0
2015-09-02T22:14:36.233Z
2015-09-02T22:14:36.233Z
carlcs
<p><a href="https://craftcms.stackexchange.com/questions/418/how-do-i-reference-the-settings-of-my-plugin">This question and answer</a> explains how to access a plugin's settings from elsewhere in the plugin's PHP code.</p>

<p>How would I access these settings from within a template? Or this impossible and I'd have to pass the values into the template when rendering it? ie, in a Controller action:</p>

<pre class="lang-php prettyprint-override"><code>$settings = craft()-&gt;plugins-&gt;getPlugin('myPlugin')-&gt;getSettings();
$templateVars = array(
    'foo' =&gt; $settings-&gt;foo,
);
$this-&gt;renderTemplate('myPlugin/templateName', $templateVars);
</code></pre>

<plugin-development><templating><settings>
How do I reference the settings of my plugin from a template?
# How do I reference the settings of my plugin from a template?

(Asked by: username_0 on 2015-09-02)

This question and answer explains how to access a plugin's settings from elsewhere in the plugin's PHP code.
How would I access these settings from within a template? Or this impossible and I'd have to pass the values into the template when rendering it? ie, in a Controller action:
$settings = craft()->plugins->getPlugin('myPlugin')->getSettings();
$templateVars = array(
    'foo' => $settings->foo,
);
$this->renderTemplate('myPlugin/templateName', $templateVars);

**Tags:** plugin-development, templating, settings


---

## 3 answers

### Answer by username_3 on 2015-09-02. Score: 4 | Accepted answer

Not sure if there's a build in way, but you can set up a template variable that returns the settings model.
class MyPluginVariable
{
    public function settings()
    {
        return craft()->plugins->getPlugin('myPlugin')->getSettings();
    }
}

Then access it in your template.
{% set settings = craft.myPlugin.settings %}

> **Comments:**
> **username_0**: Thanks Carl. Looks like that's the closest I'm going to get.  

---

### Answer by username_1 on 2017-12-11. Score: 6

In more recent versions of Craft 2.x (I forget when it was added), you can simply do this without needing a plugin:
craft.config.get('setting', 'plugin')

Where 'plugin' is the name of your plugin's config file (sans .php).
If you want to do this in Craft 3, you'd do:
craft.app.getModule('pluginHandle').getSettings().mySetting


---

### Answer by username_2 on 2015-09-02. Score: 2

From what I understand the only way to get plugin info back (in a template) is by doing:
{% set plugin = craft.plugins.getPlugin('PluginHandle') %}

This returns an instance of PluginVariable for your plugin, so you have access to any method detailed in craft/app/variables/PluginVariable.php (the craft class reference)
It looks like the getSettings() function isn't exposed in this, so I don't think its possible.
I could be wrong and there could be a way, but I couldn't figure it out from a quick look over the code :/

> **Comments:**
> **username_0**: Thanks Alec - that's as far as I'd got with looking around, so good to have it confirmed!  

---

