To have a variable available in your views and elements try this in
your controller (or AppController):
function beforeRender()
{
$this->set('variable', 'whatever you want');
}
In your views and elements you should be able to access $variable.
On Mar 22, 9:36 pm, "dizz" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am trying to set a variable in my AppController to be accessed by
> all controllers. I have an element on all of my pages that displays
> last user logins.
>
> At first I was trying to use the User model in the AppController by
> using the $uses variable but for some reason the PageController was
> not overridden (but all other controllers worked fine). Then I was
> pointed to the requestAction method. I am now trying to set the
> variable using the requestAction method but it keeps on looping.
>
> Below is the code for my AppController
>
> function beforeFilter () {
> if ($this->action != 'login' && $this->action != 'logout' &&
> $this->action != 'getLogins') {
>
> $this->checkSession();
> $this->set("user_data", $this->Session->read('User'));
> $this->set('login_data',
> $this->requestAction('/users/getLogins',
> array('return')));
> }
> }
>
> Below is the code for my UsersController
>
> function getLogins () {
> $this->User->Login->findAll();
> }
>
> Any help would be greatly appreciated. Thanks,
> -Andrew
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---