Re: can you use elements in a layout?

2007-05-01 Thread Toad

Hi Damien,
In my solution i do the following;
1. When the user logs in i set a session variable in my user
controller/login action:
 if(($user = $this->User->validateLogin($this->data['User']))
== true){
   ...
   $this->Session->write('User', $user);
   ...
   }
2. Within an element i write:
  $User = $session->read('User');
   and then do with $User whatever i need.
Hope this will help.
Regards.



On Apr 26, 12:34 am, Damien <[EMAIL PROTECTED]> wrote:
> Now I'm stopping to think about this a bit more, I've got another
> question related to this...
>
> How do you actually check to see whether the user is logged in? I was
> thinking of setting something to identify the user as logged in for
> that visitor's session (e.g. their user_id) - but so far as I
> understand, you can only use $this->Session->read() in a controller?
> So how can I read the session data from an element?
>
> On Apr 25, 10:16 pm, rtconner <[EMAIL PROTECTED]> wrote:
>
> > I've used Elements in my layouts frequently. There is no reason not to
> > do it. $this->renderElement(...);
> > Yes, you can put logic into your layout. Best practices depends on
> > your system. If you want to redirect them elsewhere, if they are not
> > logged in I'd think you want to do that in a controller or componant.
> > If really depends on the auth system you are using.
>
> > I have some simple logic in my layouts that look kind of like this
> > (psuedo code)
>
> > if(user->is_logged_in)
> >   print username
> > else
> >  print Log In
>
> > On Apr 25, 2:47 pm, Damien <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I'm quite new to working with Cake and I'm pretty sure that I'm asking
> > > something obvious - so I'm sorry for that in advance. In my defence,
> > > I've tried checking the manual, API, searching on here etc. and
> > > haven't found the answer to my question (or maybe not understood the
> > > answer to my question!).
>
> > > I'm going to have a login box on every page of my site which will form
> > > part of the site header / mast head.
>
> > > If the user is not logged in it will display the login box, and if
> > > they are it'll display some member-only type functions (e.g. edit
> > > profile, logout etc.).
>
> > > I'm not quite sure how to go about that in Cake - in terms of where to
> > > define my various pieces of code. Obviously the login processing stuff
> > > belongs in a user controller, but other than that?
>
> > > I'm thinking that my login box is what Cake terms an 'element' - I've
> > > only come across these used in views; can they also be used in a
> > > layout (is there are significant difference between layouts and
> > > views)?
>
> > > Assuming that's right, where do I check to see if the user is logged
> > > in or out - is it "appropriate" (i.e. best practice) to put that logic
> > > in the layout? That seems to make sense to me since it's only deciding
> > > which display element to use?
>
> > > Thanks in advance for putting up with my questions.
>
> > > Damien


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: can you use elements in a layout?

2007-04-25 Thread Damien

Ok. I'll take a look. Many thanks for your help!

On Apr 25, 11:01 pm, rtconner <[EMAIL PROTECTED]> wrote:
> You are going to need to use an Auth component of some sort. There are
> several available on the bakery. As of yet there is no standard way of
> doing Authentication. I guess look over
> othAuth, dAuth, obAuth, etc and see which one you want to use, and
> then I think you can work from there finding out how you will handle
> accessing authentication data.
>
> On Apr 25, 3:34 pm, Damien <[EMAIL PROTECTED]> wrote:
>
> > Now I'm stopping to think about this a bit more, I've got another
> > question related to this...
>
> > How do you actually check to see whether the user is logged in? I was
> > thinking of setting something to identify the user as logged in for
> > that visitor's session (e.g. their user_id) - but so far as I
> > understand, you can only use $this->Session->read() in a controller?
> > So how can I read the session data from an element?
>
> > On Apr 25, 10:16 pm, rtconner <[EMAIL PROTECTED]> wrote:
>
> > > I've used Elements in my layouts frequently. There is no reason not to
> > > do it. $this->renderElement(...);
> > > Yes, you can put logic into your layout. Best practices depends on
> > > your system. If you want to redirect them elsewhere, if they are not
> > > logged in I'd think you want to do that in a controller or componant.
> > > If really depends on the auth system you are using.
>
> > > I have some simple logic in my layouts that look kind of like this
> > > (psuedo code)
>
> > > if(user->is_logged_in)
> > >   print username
> > > else
> > >  print Log In
>
> > > On Apr 25, 2:47 pm, Damien <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > I'm quite new to working with Cake and I'm pretty sure that I'm asking
> > > > something obvious - so I'm sorry for that in advance. In my defence,
> > > > I've tried checking the manual, API, searching on here etc. and
> > > > haven't found the answer to my question (or maybe not understood the
> > > > answer to my question!).
>
> > > > I'm going to have a login box on every page of my site which will form
> > > > part of the site header / mast head.
>
> > > > If the user is not logged in it will display the login box, and if
> > > > they are it'll display some member-only type functions (e.g. edit
> > > > profile, logout etc.).
>
> > > > I'm not quite sure how to go about that in Cake - in terms of where to
> > > > define my various pieces of code. Obviously the login processing stuff
> > > > belongs in a user controller, but other than that?
>
> > > > I'm thinking that my login box is what Cake terms an 'element' - I've
> > > > only come across these used in views; can they also be used in a
> > > > layout (is there are significant difference between layouts and
> > > > views)?
>
> > > > Assuming that's right, where do I check to see if the user is logged
> > > > in or out - is it "appropriate" (i.e. best practice) to put that logic
> > > > in the layout? That seems to make sense to me since it's only deciding
> > > > which display element to use?
>
> > > > Thanks in advance for putting up with my questions.
>
> > > > Damien


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: can you use elements in a layout?

2007-04-25 Thread rtconner

You are going to need to use an Auth component of some sort. There are
several available on the bakery. As of yet there is no standard way of
doing Authentication. I guess look over
othAuth, dAuth, obAuth, etc and see which one you want to use, and
then I think you can work from there finding out how you will handle
accessing authentication data.

On Apr 25, 3:34 pm, Damien <[EMAIL PROTECTED]> wrote:
> Now I'm stopping to think about this a bit more, I've got another
> question related to this...
>
> How do you actually check to see whether the user is logged in? I was
> thinking of setting something to identify the user as logged in for
> that visitor's session (e.g. their user_id) - but so far as I
> understand, you can only use $this->Session->read() in a controller?
> So how can I read the session data from an element?
>
> On Apr 25, 10:16 pm, rtconner <[EMAIL PROTECTED]> wrote:
>
> > I've used Elements in my layouts frequently. There is no reason not to
> > do it. $this->renderElement(...);
> > Yes, you can put logic into your layout. Best practices depends on
> > your system. If you want to redirect them elsewhere, if they are not
> > logged in I'd think you want to do that in a controller or componant.
> > If really depends on the auth system you are using.
>
> > I have some simple logic in my layouts that look kind of like this
> > (psuedo code)
>
> > if(user->is_logged_in)
> >   print username
> > else
> >  print Log In
>
> > On Apr 25, 2:47 pm, Damien <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I'm quite new to working with Cake and I'm pretty sure that I'm asking
> > > something obvious - so I'm sorry for that in advance. In my defence,
> > > I've tried checking the manual, API, searching on here etc. and
> > > haven't found the answer to my question (or maybe not understood the
> > > answer to my question!).
>
> > > I'm going to have a login box on every page of my site which will form
> > > part of the site header / mast head.
>
> > > If the user is not logged in it will display the login box, and if
> > > they are it'll display some member-only type functions (e.g. edit
> > > profile, logout etc.).
>
> > > I'm not quite sure how to go about that in Cake - in terms of where to
> > > define my various pieces of code. Obviously the login processing stuff
> > > belongs in a user controller, but other than that?
>
> > > I'm thinking that my login box is what Cake terms an 'element' - I've
> > > only come across these used in views; can they also be used in a
> > > layout (is there are significant difference between layouts and
> > > views)?
>
> > > Assuming that's right, where do I check to see if the user is logged
> > > in or out - is it "appropriate" (i.e. best practice) to put that logic
> > > in the layout? That seems to make sense to me since it's only deciding
> > > which display element to use?
>
> > > Thanks in advance for putting up with my questions.
>
> > > Damien


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: can you use elements in a layout?

2007-04-25 Thread Damien

Sorry - I meant "So how can I read the session data from a layout"?
(NOT from an element)


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: can you use elements in a layout?

2007-04-25 Thread Damien

Now I'm stopping to think about this a bit more, I've got another
question related to this...

How do you actually check to see whether the user is logged in? I was
thinking of setting something to identify the user as logged in for
that visitor's session (e.g. their user_id) - but so far as I
understand, you can only use $this->Session->read() in a controller?
So how can I read the session data from an element?

On Apr 25, 10:16 pm, rtconner <[EMAIL PROTECTED]> wrote:
> I've used Elements in my layouts frequently. There is no reason not to
> do it. $this->renderElement(...);
> Yes, you can put logic into your layout. Best practices depends on
> your system. If you want to redirect them elsewhere, if they are not
> logged in I'd think you want to do that in a controller or componant.
> If really depends on the auth system you are using.
>
> I have some simple logic in my layouts that look kind of like this
> (psuedo code)
>
> if(user->is_logged_in)
>   print username
> else
>  print Log In
>
> On Apr 25, 2:47 pm, Damien <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I'm quite new to working with Cake and I'm pretty sure that I'm asking
> > something obvious - so I'm sorry for that in advance. In my defence,
> > I've tried checking the manual, API, searching on here etc. and
> > haven't found the answer to my question (or maybe not understood the
> > answer to my question!).
>
> > I'm going to have a login box on every page of my site which will form
> > part of the site header / mast head.
>
> > If the user is not logged in it will display the login box, and if
> > they are it'll display some member-only type functions (e.g. edit
> > profile, logout etc.).
>
> > I'm not quite sure how to go about that in Cake - in terms of where to
> > define my various pieces of code. Obviously the login processing stuff
> > belongs in a user controller, but other than that?
>
> > I'm thinking that my login box is what Cake terms an 'element' - I've
> > only come across these used in views; can they also be used in a
> > layout (is there are significant difference between layouts and
> > views)?
>
> > Assuming that's right, where do I check to see if the user is logged
> > in or out - is it "appropriate" (i.e. best practice) to put that logic
> > in the layout? That seems to make sense to me since it's only deciding
> > which display element to use?
>
> > Thanks in advance for putting up with my questions.
>
> > Damien


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: can you use elements in a layout?

2007-04-25 Thread rtconner

I've used Elements in my layouts frequently. There is no reason not to
do it. $this->renderElement(...);
Yes, you can put logic into your layout. Best practices depends on
your system. If you want to redirect them elsewhere, if they are not
logged in I'd think you want to do that in a controller or componant.
If really depends on the auth system you are using.

I have some simple logic in my layouts that look kind of like this
(psuedo code)

if(user->is_logged_in)
  print username
else
 print Log In


On Apr 25, 2:47 pm, Damien <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm quite new to working with Cake and I'm pretty sure that I'm asking
> something obvious - so I'm sorry for that in advance. In my defence,
> I've tried checking the manual, API, searching on here etc. and
> haven't found the answer to my question (or maybe not understood the
> answer to my question!).
>
> I'm going to have a login box on every page of my site which will form
> part of the site header / mast head.
>
> If the user is not logged in it will display the login box, and if
> they are it'll display some member-only type functions (e.g. edit
> profile, logout etc.).
>
> I'm not quite sure how to go about that in Cake - in terms of where to
> define my various pieces of code. Obviously the login processing stuff
> belongs in a user controller, but other than that?
>
> I'm thinking that my login box is what Cake terms an 'element' - I've
> only come across these used in views; can they also be used in a
> layout (is there are significant difference between layouts and
> views)?
>
> Assuming that's right, where do I check to see if the user is logged
> in or out - is it "appropriate" (i.e. best practice) to put that logic
> in the layout? That seems to make sense to me since it's only deciding
> which display element to use?
>
> Thanks in advance for putting up with my questions.
>
> Damien


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



can you use elements in a layout?

2007-04-25 Thread Damien

Hi,

I'm quite new to working with Cake and I'm pretty sure that I'm asking
something obvious - so I'm sorry for that in advance. In my defence,
I've tried checking the manual, API, searching on here etc. and
haven't found the answer to my question (or maybe not understood the
answer to my question!).

I'm going to have a login box on every page of my site which will form
part of the site header / mast head.

If the user is not logged in it will display the login box, and if
they are it'll display some member-only type functions (e.g. edit
profile, logout etc.).

I'm not quite sure how to go about that in Cake - in terms of where to
define my various pieces of code. Obviously the login processing stuff
belongs in a user controller, but other than that?

I'm thinking that my login box is what Cake terms an 'element' - I've
only come across these used in views; can they also be used in a
layout (is there are significant difference between layouts and
views)?

Assuming that's right, where do I check to see if the user is logged
in or out - is it "appropriate" (i.e. best practice) to put that logic
in the layout? That seems to make sense to me since it's only deciding
which display element to use?

Thanks in advance for putting up with my questions.

Damien


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---