set function that can be accessed on every page

Hi, I’ve created a function that generates a list of documents owned by the user. I would like these documents to be listed in the menu as a submenu section. Where do I need to call this function to make sure that every page has access to it? I was thinking about adding a line of code to the Controller class but I would rather not work in core files. Do you guys have a suggestion? Thanks!

Michiel

Controller is not a core class… it is a wrapper of CController which is a core class.

So you can safely put your code in Controller class. Like your decision to not edit core files… always wrap them, never edit.

The best way to solve your problem would be to create a widget that display your list.

To show your list on every page add the widget at the appropiate place to your layout file.

This ^^

You will find the file in components/controller.php

Make a function like


public function myfunction($id) {

...

}

Access it anywhere with


$this->myfunction(n)

where n = your userid