The controller that your home.ctp view uses is the PagesController
The error is showing that your User model doesn't exist within your
Pages controller.
Did you set up your AppController to automatically include the Users
model to all controllers?
e.g. in your AppContoller definition you should have the code
var $uses = array ('User'); // this is the important one.
var $components = array('DarkAuth');
once the component is working correctly you can control content in the
veiw using the switch:
if ( !empty($DarkAuth_User) ) {
echo "Some content for logged in people!";
} else {
echo "Content for non-authenticated people";
}
Hope this helps.
On 15 Mar, 20:31, Stefano <[EMAIL PROTECTED]> wrote:
> [Xposted onhttp://bakery.cakephp.org/articles/view/darkauth-another-way]
>
> I'm trying to implement this auth system in one of my projects. Now I
> have a question: I'm trying to add authentication to my home page
> (that is home.ctp). Now, this page has no controller, so how can
> darkauth e aware of it?
>
> I'll try to describe my problem more in depth: I've successfully
> applied darkauth to a User model, so if I try to access /cake/users I
> get my login screen, and everything works fine.
> Now, if I want to go back to my site homepage, located in /cake, I get
> an error:
>
> Undefined property: PagesController::$User [APP/controllers/components/
> dark_auth.php, line 248]
>
> Line 248 says:
>
> $check = $this->controller->{$this->user_model_name}-
>
> >find($conditions);
>
> And I can understand the error, since home.ctp has no controller
> associated.
> home.ctp shows correctly if I logout from darkauth...
> What if I'd like to show a different content on the home page for
> logged/unlogged users? Is it possibile?
> Thanks in advance and sorry for the long post.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---