Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-11T19:29:37.687Z
Answers.LastActivityDate: 2017-12-11T19:29:37.687Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-03T08:50:52.653Z
Answers.Text: Thanks Alec - that's as far as I'd got with looking around, so good to have it confirmed!
Answers.UserDisplayName: Phil Gyford
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-02T22:04:57.580Z
Answers.LastActivityDate: 2015-09-02T22:04:57.580Z
Answers.UserDisplayName: Alec Ritson
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-03T08:51:32.173Z
Answers.Text: Thanks Carl. Looks like that's the closest I'm going to get.
Answers.UserDisplayName: Phil Gyford
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-02T22:14:36.233Z
Answers.LastActivityDate: 2015-09-02T22:14:36.233Z
Answers.UserDisplayName: carlcs
Body: <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>
  
Tags: <plugin-development><templating><settings>
Title: How do I reference the settings of my plugin from a template?
ThreadText: # How do I reference the settings of my plugin from a template?
  
  (Asked by: username_0 on 2015-09-02)
  
  [This question and answer](https://craftcms.stackexchange.com/questions/418/how-do-i-reference-the-settings-of-my-plugin) 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:
  
  ```php
  $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](http://buildwithcraft.com/docs/plugins/variables) 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](http://buildwithcraft.com/classreference/variables/PluginVariable))
  
  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 username_2 - that's as far as I'd got with looking around, so good to have it confirmed!  
  
  ---
  
  