Where To Put This Function?

Hi there,

I’m writing a function to create a menu that will be called on all pages. (Like this).

My question is, where should this function go? Should I create a new file under components or is there somewhere else?

Thanks in advance!

I usually put this kind of methods into my base Controller class that all other controllers extend from.


I agree with nineinchnick

But If you want this menu as global for Controllers that extend different base controller you could make a file (for example Utils.php) with ths code

class Utils {

public static function getMenu() {

 //return your menu



Use it in view or layout like that

$yourmenu = Utils::getMenu()

Thanks guys, much appreciated.