1

I am brand new to craft and have loved it so far. Only area that I'm having a hard time understanding is why I cannot use my template variables in my templates.

I am routing news/ to an action which then uses the renderTemplate() method to do just that...render the template. The result is sent to the browser but it is accompanied by the following php error:

Fatal error: Cannot declare class Craft\WassermanNewsVaraible, because the name 
is already in use in /usr/share/nginx/craft/plugins/myPlugin/variables/MyPluginVariable.php on line 5

So that tells me that the class is obviously already declared somewhere. If so how can I access it? I am currently trying to access it as the documentation describes and is shown below:

{% for item in craft.myPlugin.myMethod() %}
  <div>
   Test
  </div>
{% endfor %}

Here is my template variable class which is in myPlugin/variables/

namespace Craft;

class MyPluginVaraible
{
    public function myMethod(){
        craft()->myPlugin->myMethod(); //which is in the service
    }
}

Is there a difference between how templates are rendered via controllers as opposed to the regular behavior? I saw that the method had a second parameter however I still could not insatiate my template variables to pass that way as it was still already declared somewhere.

I've been banging away at this one for a while. Any help or insight would be much appreciated.

1 Answer 1

3

MyPluginVaraible Note the spelling of the highlighted word...

0

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.