When it comes to user information (the logged-in user) I set that
user's data in AppController so that the username and other things are
available in any view. The following little tricks are common when
using AuthComponent for authentication:
in AppController::beforeFilter:
$user = $this->Auth->user();
$this->set('auth', $user );
So if what you want to do is along these lines it might be a good
idea?
The User model is also always available in any controller as:
$model =& $this->Auth->getModel();
$data = $model->some_method()
$this->set('some_data', $data );
On Mar 26, 3:15 pm, Eber Freitas Dias <[email protected]> wrote:
> A controller can use more than one model. You just need to set which ones
> you want on the class variable $uses:
>
> var $uses = array('Movie', 'User');
>
> A controller can use no table at all, you just need to leave that array
> empty.
>
> This will load both Models on each and every method (I guess) so you can
> load it just where you want with loadModel
> (http://api.cakephp.org/class/controller#method-ControllerloadModel) or
> ClassRegistry::init('Model')
> (http://api.cakephp.org/class/class-registry#method-ClassRegistryinit).
>
> Then, just follow Stu's tip!
>
> On Thu, Mar 26, 2009 at 10:57 AM, jonas <[email protected]>wrote:
>
>
>
>
>
> > I wasn't refering to that particular problem.
>
> > On 26 mrt, 14:54, Stu <[email protected]> wrote:
> > > You cannot do that from the view, if you need to have information in
> > > the view you can do this in the controller:
>
> > > $this->set('variableName', value);
>
> > > then by using $variableName in your view.
>
> > > You can put all your user info in an array and use that in your view.
>
> > > On Mar 26, 9:43 am, jonas <[email protected]> wrote:
>
> > > > Hi,
>
> > > > Let's say I wanted to create a movietrailer website.
> > > > First thing I would do is create a movie table, controller, model and
> > > > view.
> > > > There my movietrailer website is done!
> > > > But I want to add a user auth system. So I create a users table,
> > > > controller, model and view.
>
> > > > But what if I wanted to show something from the users model (some site
> > > > visiting information) on the movie view ?
>
> > > > Is this way cake has support for components ?
> > > > Or can I just do $this->Users->some_method(); from the movie view/
> > > > controller ?
>
> > > > Regards
>
> > > > Jonas
>
> --
> Éber Freitas Dias
>
> www.eberfdias.comwww.dejamps.net
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---