<p>Data in plugins is not automatically made available to twig templates.</p>

<p>To make something available, you need to create a folder in your plugin master folder called <code>variables</code> and in that folder create a class <code>PluginNameVariable.php</code></p>

<p>Here's an example of what you might put in that file:</p>

<pre><code>&lt;?php

namespace Craft;

class YourPluginNameVariable
{

    public function developerName()
    {
        return craft()-&gt;yourPluginsName-&gt;someServiceMethodThatReturnsTheDeveloperName();
    }

}
</code></pre>

<p>This would make a template variable available in your templates via</p>

<pre><code>{{ craft.yourPluginName.developerName }}
</code></pre>

<p>Here are the Craft Docs for this - <a href="https://craftcms.com/docs/plugins/variables" rel="nofollow noreferrer">https://craftcms.com/docs/plugins/variables</a></p>

CC BY-SA 3.0
2017-04-25T05:19:02.413Z
Hi thanks for your response, I just followed what you've said but now, I'm getting an error  "Property "Craft\WebApp.crmportal" is not defined."
lance adrianne dela cruz
CC BY-SA 3.0
2017-04-25T05:19:18.063Z
*crmportal is maybe my handle name for the plugin
lance adrianne dela cruz
CC BY-SA 3.0
2017-04-25T05:21:24.777Z
Probable a case sensitivity issue.  Your best bet is to generate your plugin infrastructure using https://pluginfactory.io/ - this will give you all the structure correctly done & named, you just fill in the methods basically (choose variable in that!).  From there it's up to your PHP skills (start another question if you have different issues)
Jeremy Daalder
CC BY-SA 3.0
2017-04-25T05:24:05.400Z
ok sir . i'll try that
lance adrianne dela cruz
CC BY-SA 3.0
2017-04-25T07:25:47.033Z
I try using pluginfactory.io but nothing happens. it stays the same. having an error = " Property "Craft\WebApp.crmportal" is not defined. "
lance adrianne dela cruz
CC BY-SA 3.0
2017-04-25T07:27:41.370Z
Add the twig causing the error
Jeremy Daalder
CC BY-SA 3.0
2017-04-25T05:10:32.287Z
2017-04-25T05:10:32.287Z
Jeremy Daalder
<p>I'm constructing a plug-in and I'm new to it. </p>

<p>I want to print to the screen in my template the name of the developer, by accessing the <code>getDeveloper()</code> method in my <code>Plugin.php</code>. The problem is instead of showing the name of the developer, it throws an error saying <code>Class Craft\CrmPortalVariable</code> not found.</p>

<plugin-development>
How to make plugin developer name available in templates?
# How to make plugin developer name available in templates?

(Asked by: username_0 on 2017-04-25)

I'm constructing a plug-in and I'm new to it.

I want to print to the screen in my template the name of the developer, by accessing the `getDeveloper()` method in my `Plugin.php`. The problem is instead of showing the name of the developer, it throws an error saying `Class Craft\CrmPortalVariable` not found.

**Tags:** plugin-development

---

## 1 answers

### Answer by username_1 on 2017-04-25. Score: 4 | Accepted answer

Data in plugins is not automatically made available to twig templates.
To make something available, you need to create a folder in your plugin master folder called variables and in that folder create a class PluginNameVariable.php
Here's an example of what you might put in that file:
yourPluginsName->someServiceMethodThatReturnsTheDeveloperName();
    }

}

This would make a template variable available in your templates via
{{ craft.yourPluginName.developerName }}

Here are the Craft Docs for this - https://craftcms.com/docs/plugins/variables

> **Comments:**
> **username_0**: Hi thanks for your response, I just followed what you've said but now, I'm getting an error  "Property "Craft\WebApp.crmportal" is not defined."  
> **username_0**: *crmportal is maybe my handle name for the plugin  
> **username_1**: Probable a case sensitivity issue.  Your best bet is to generate your plugin infrastructure using https://pluginfactory.io/ - this will give you all the structure correctly done & named, you just fill in the methods basically (choose variable in that!).  From there it's up to your PHP skills (start another question if you have different issues)  
> **username_0**: ok sir . i'll try that  
> **username_0**: I try using pluginfactory.io but nothing happens. it stays the same. having an error = " Property "Craft\WebApp.crmportal" is not defined. "  
> **username_1**: Add the twig causing the error  

---

