After registration, redirect to another Cakephp layout

Asked

Viewed 1,118 times

1

I have a layout for the home page of my project, with only a registration form and nothing else. After the person signs up, they are redirected to another page, completely different from the home page. My controller looks like this:

if ($this->User->save($this->request->data){
   $this->redirect(array('controller' => 'users', 'action' => 'index'));
}

I created another controller called UsersController and a method called index(), and inside it I put it like this:

function index(){
    $this->layout = 'user';
}

Registration occurs normally, only the layout does not change, is on the same start screen. I have tried to put this code in the beforeFilter() but it didn’t help either. How can I make it work?

  • You have the files app/View/Users/index.ctp and app/View/Layouts/user.ctp? What do you mean, "stays on the same home screen"? No user/index view appears?

  • So, the Layouts/user.ctp I have, the Users/index.ctp does not ?

1 answer

1

I solved the problem, created the Users folder inside the view with the index.ctp file Thanks for the tip

  • Glad you solved it. Just adding, the idea of the layout is to be the "shell" of the view. The site content should be in the view (the index.ctp that was missing).

  • Thanks for the tip friend, but I came up with another question. How do I open a session after this user register and be redirected? That is, protect the User page in case? I do not know if the Auth would be for that or would have to use Session

  • Auth already uses Session internally for this. But if you are having difficulties, I suggest opening a new specific question about this.

  • Okay buddy, thanks, I’ll do it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.