3

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();
    }
}
4
  • Can you please provide some more info. What is that leads function?
    – carlcs
    Commented May 12, 2015 at 5:36
  • Sorry updated my question with more info.
    – R0wan
    Commented May 12, 2015 at 5:51
  • I could be totally wrong, but you might try {% set leads = craft.lead.infopack.getPacks() %} Commented May 12, 2015 at 5:59
  • No luck - with {% set leads = craft.lead.infopack.getPacks() %}.
    – R0wan
    Commented May 12, 2015 at 6:05

2 Answers 2

4

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

4

carlcs 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.