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.


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:


namespace Craft;

class YourPluginNameVariable

    public function developerName()
        return craft()->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

  • 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." Apr 25 '17 at 5:19
  • *crmportal is maybe my handle name for the plugin Apr 25 '17 at 5:19
  • Probable a case sensitivity issue. Your best bet is to generate your plugin infrastructure using 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) Apr 25 '17 at 5:21
  • ok sir . i'll try that Apr 25 '17 at 5:24
  • 1
    Add the twig causing the error Apr 25 '17 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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