Spica Posted March 5, 2016 Share Posted March 5, 2016 $p = new Page(); $p->template = 'mytp'; $p->name = $myname; $p->save(); $session->redirect($p->url, false); The redirection fails. How to do it? Link to comment Share on other sites More sharing options...
BitPoet Posted March 5, 2016 Share Posted March 5, 2016 Your page needs a parent. 2 Link to comment Share on other sites More sharing options...
Spica Posted March 5, 2016 Author Share Posted March 5, 2016 well, I shortened it. It has a parent, name, title and creaded user. here the full code $p = new Page(); $p->template = 'mytp'; $p->name = $myname; $p->parent_id = $myparentid; $p->name = $myName; $p->title = $mytitle; $p->created_users_id = $user->id; $p->save(); $session->redirect($p->url, false); Creation of pages is working. I used to stay at the page where new pages get created: $session->redirect("./", false); but now want to redirect to the newly created page Link to comment Share on other sites More sharing options...
horst Posted March 5, 2016 Share Posted March 5, 2016 what do you get if you echo out or var_dump() $p->viewable() // and / or $p->url // and / or $p->id right after $p->save() ? Link to comment Share on other sites More sharing options...
Spica Posted March 6, 2016 Author Share Posted March 6, 2016 Hmm. This morning my code is running without errors. Maybe I was to tired. Thanks for the help anyway. To be save I now use if ($p->viewable()) { $session->redirect($p->url, false); } else { $session->redirect("./", false); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now