<p><a href="https://craftcms.stackexchange.com/a/9695/57">carlcs</a> is correct (as usual).</p>

<p>You can only have one variable class that maps to <code>craft.pluginName</code>, but you can have methods inside that class that map to other variable classes.</p>

CC BY-SA 3.0
2015-05-12T17:56:35.653Z
2015-05-12T17:56:35.653Z
2017-04-13T12:51:00.200Z
Brad Bell
<p>I think you can only have one variable class. So the solution you posted is the only way that works.</p>

CC BY-SA 3.0
2015-05-12T06:21:07.543Z
2015-05-12T06:21:07.543Z
carlcs
<p>Making a plugin.</p>

<p>I can't seem to get this <code>{% set leads = craft.lead_infopack.getPacks() %}</code> to fire from within a template. </p>

<p>Plugin name: lead</p>

<p>Here's a look inside my variables class.</p>

<p>Lead_InfopackVariable.php:</p>

<pre><code>class Lead_InfopackVariable
{ 
    public function getPacks()
    {
        return craft()-&gt;lead_infopack-&gt;leads();
    }
</code></pre>

<p>The leads function calls a service that outputs all entries within my 'infopack' table.</p>

<p>If I write it like this it works <code>{% set leads = craft.lead.getPacks() %}</code></p>

<p>LeadVariable.php:</p>

<pre><code>class LeadVariable
{ 
    public function getPacks()
    {
        return craft()-&gt;lead_infopack-&gt;leads();
    }
}
</code></pre>

CC BY-SA 3.0
2015-05-12T05:36:40.990Z
Can you please provide some more info. What is that leads function?
carlcs
CC BY-SA 3.0
2015-05-12T05:51:40.037Z
Sorry updated my question with more info.
R0wan
CC BY-SA 3.0
2015-05-12T05:59:58.293Z
I could be totally wrong, but you might try `{% set leads = craft.lead.infopack.getPacks() %}`
Douglas McDonald
CC BY-SA 3.0
2015-05-12T06:05:00.440Z
No luck - with `{% set leads = craft.lead.infopack.getPacks() %}`.
R0wan
<plugin-development>
Namespace issues when calling a plugin variable
# Namespace issues when calling a plugin variable

(Asked by: username_0 on 2015-05-12)

Making a plugin.
I can't seem to get this {% set leads = craft.lead_infopack.getPacks() %} to fire from within a template. 
Plugin name: lead
Here's a look inside my variables class.
Lead_InfopackVariable.php:
class Lead_InfopackVariable
{ 
    public function getPacks()
    {
        return craft()->lead_infopack->leads();
    }

The leads function calls a service that outputs all entries within my 'infopack' table.
If I write it like this it works {% set leads = craft.lead.getPacks() %}
LeadVariable.php:
class LeadVariable
{ 
    public function getPacks()
    {
        return craft()->lead_infopack->leads();
    }
}

**Tags:** plugin-development
> **Comments:**
> **username_1**: Can you please provide some more info. What is that leads function?  
> **username_0**: Sorry updated my question with more info.  
> **username_2**: I could be totally wrong, but you might try `{% set leads = craft.lead.infopack.getPacks() %}`  
> **username_0**: No luck - with `{% set leads = craft.lead.infopack.getPacks() %}`.  

---

## 2 answers

### Answer by username_1 on 2015-05-12. Score: 4 | Accepted answer

I think you can only have one variable class. So the solution you posted is the only way that works.


---

### Answer by username_3 on 2015-05-12. Score: 4

[carlcs](https://craftcms.stackexchange.com/a/9695/57) is correct (as usual).

You can only have one variable class that maps to `craft.pluginName`, but you can have methods inside that class that map to other variable classes.


---

