Custom view renderer

Just messing around with writing a simple custom view renderer but can’t seem to figure out what is incorrect.

Using:


    public function renderFile($context,$sourceFile,$data,$return) {

        $data['this'] = $context;

        extract($data);

        ob_start();

        include($sourceFile);

        $contents = ob_get_contents();

        ob_end_clean();

        if($return) {

            return $contents;

        } else {

            echo $contents;

        }

    }

But get the error:

Property "EMyCustomViewRenderer.pageTitle" is not defined.

Any ideas?

your


EMyCustomViewRenderer

class should declare elsewhere a PageTitle property that isn’t filled.

You can’t overwrite $this, not even by using extract. So in your view file $this still refers to the view renderer, not the controller/widget you passed in $context