I'm confused..... I don't get why you're adding the same beforeFilter() to post_controller....
However, speaking in GENERAL TERMS: If you set a beforeFilter() in app_controller and also NEED a beforeFilter() in other controllers, you simply need to ensure that in that beforeFilter() you call parent::beforeFilter() (before of after your code; which ever suits you purposes). On Mon, Apr 7, 2008 at 5:03 AM, CakeHopeFull <[EMAIL PROTECTED]> wrote: > > Hello, > > on my app_controller.php file I have > > [code] > class AppController extends Controller { > function beforeFilter() { > $this->set('SiteRoot', '/bla/'); > //default menu selected set to 0, otherwise cake lets me > know I > have an undifined var in my defualt view > $this->set('MenuSelected', '0'); > } > } > > [/code] > > This works great, but when I add a before filter to the posts > controller I get "Notice (8): Undefined variable: SiteRoot [APP/views/ > layouts/default.ctp, line 127" > [code] > class PostsController extends AppController { > function beforeFilter() { > $this->set('SiteRoot', '/bla/'); > //default menu selected set to 0, otherwise cake lets me > know I > have an undifined var in my defualt view > $this->set('MenuSelected', '0'); > } > function index() { > $this->set('posts', $this->Post->find('all')); > } > > } > [/code] > > How do I go about setting up App wide vars that are passed to my > template, but also set those vars if needed in other controllers? I > know I can in my posts_controller > > do: > [code] > function index() { > $this->set('posts', $this->Post->find('all')); > $this->set('MenuSelected', '1'); > } > [/code] > > but then I would have to add the MenuSelected in the index(), add(), > delete(), edit() portions, and that is well repeating.... any ideas > on what I am doing wrong? > > Thank You, > Chris > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---