1

I'm trying to create a class in EE, but for some reason it just won't work for me. I've even went as far as making it as easy as possible, but I always get:

The following tag has a syntax error:

{exp:my_class_name:testfunction}

Please correct the syntax in your template.

Here's the simple class:

class My_class_name {

    public $return_data;

    public function __construct(){
        $this->EE =& get_instance();
    }

    public static function usage(){
        ob_start();
        ?>
        Coming Soon, this is just filler for now.
        <?php
        $buffer = ob_get_contents();
        ob_end_clean();
        return $buffer;
    }

    public function testfunction(){
        $this->return_data = ee()->TMPL->tagdata;
    }

}

and usage:

    {exp:my_class_name:testfunction}
    hey
    {/exp:my_class_name:testfunction}
  • can u see your plugin in CP plugin list ? – Max Lazar Sep 30 '14 at 5:18
  • BTW: "$this->EE =& get_instance();" is redundant now as you're using the super global ee() – Peter Lewis Sep 30 '14 at 7:47
3

Your plugin class method needs to return the (parsed) tagdata instead of setting the $this->return_data property. The latter is only needed if the class constructor is used for template output. So:

public function testfunction()
{
    return ee()->TMPL->tagdata;
}
| improve this answer | |

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.