Avoid repeatetive code in view template

Hi guys, just a quick question. :smile: is there a way to extend a view template in AppView class?
I’m looking for a solution on not repeating any code that I put in my template.ctp file that looks like this:


and want to move it to AppView so I could just define like, if ($this->requests->controller) are Pages, Dealers, or whatever so I could use that extend statement there…

Elements would not serve what you need?


1 Like

Yep, that might be the best way to go.

Some suggestions from cakephp gurus at Slack.

admad [7:52 PM]
@Neil you can try overriding View::_evaluate()  and adding the `extend()` call before `include` statement

admad [7:56 PM]
but thats hackish and you could end up with a loop if not careful
so will need proper checks to decide when to extend

Looking into cells too. :smiley: