I'm not sure I got this properly, but it seems like this might help:
class PostsController extends AppController
{
function beforeFilter()
{
parent::beforeFilter(); // call the
AppController::beforeFilter()
// you other stuff here..
}
}
On Apr 7, 12:03 pm, 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---