Wednesday, August 26, 2009

Re: get profile id when user logs in

Sry Brian you are right!The relations are: User HasOne Profile and Profile belongsTo User.In profiles table i use the user_id field but in users i didn't use the profile_id.So in order to make your solution work i must add a field with that name,if there is not any other soluton.

Many thanks for your post Brian!

2009/8/26 brian <bally.zijn@gmail.com>

Use $session->read('Auth.User.profile_id') *if* your User model has
that field. You haven't explained how the association between User &
Profile has been set up, so it's difficult to say.

On Wed, Aug 26, 2009 at 12:01 PM, Paulos23<paulitostheone@gmail.com> wrote:
>
> Hello people,
> I am facing a small problem here.To get you to the point i have 2
> models User,Profile and their controllers as well.I have set up the
> relations and then i created an element which appears when user logs
> in.In the element i have put options in order to view,edit User
> details and Profile details.I have managed to pass the id of user from
> the view like this  ---->
>
> <?php echo $html->image("cog.png",array("alt" =>
> "Edit","title"=>"Edit",'url' => array('controller' => 'users',
> 'action' => 'edit',$session->read('Auth.User.id'))));?>
>
> and now i want to pass the profile id but when i do ----->
>
> <?php echo $html->image("user_go.png",array("alt" =>
> "View" ,"title"=>"View",'url' => array('controller' => 'profiles',
> 'action' => 'view',$user['Profile']['id'])));?>  i take 2 errors that
> user and profile variables are not defined.
> How can I take the profile id to pass it to the profiles_controller
> like in the users above??
> Is there any way to do it?
>
> Ty very much in advance!
> >
>




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: