davo Posted August 8, 2014 Share Posted August 8, 2014 I'm using the following template to create a new page by the user. What I'd like to do is after saving the page, immediately return the page id of the newly created page. I'm not sure if this is possible in the same page submission. Any ideas? <?php /** * Page template * This template actually creates the event for the agent */ include("./dmcheader.inc"); $event_date = $sanitizer->text($input->post->event_date); //get the details from the previous pages form $event_details = $sanitizer->textarea($input->post->event_details); $event_name = $sanitizer->text($input->post->event_name); $t = new Page(); // set the new page up $t->template = $templates->get("agent_event"); // use the template agent_event $t->parent = $pages->get(2112); // attach it to the events parent $t->title = $event_name; // use the use the name $t->agent_event_date = $event_date; // use the date - still needs work from the front end formatter and picker $t->body = $event_details; // event details go to the body $t->save(); // create the page // give current current user access to edit previously created page $user->editable_pages->add($t); $user->save('editable_pages'); ?> <title><?=$page->title?></title> </head> <div class="container" style="margin-top:30px"> <div class="col-md-4 col-md-offset-2" > <div class="panel panel-default"> <div class="panel-heading"><h3 class="panel-title"><strong><h2>Brilliant</h2></strong></h3></div> <div class="panel-body"> <p>Your event has been created <?php echo "{t->id}" ; ?></p> </div> </div> </div> </div> <?php include("./dmcfooter.inc"); Link to comment Share on other sites More sharing options...
adrian Posted August 8, 2014 Share Posted August 8, 2014 I don't think I am missing anything here. Isn't it as simple as echo'ing $t->id ? You have t->id 3 Link to comment Share on other sites More sharing options...
davo Posted August 8, 2014 Author Share Posted August 8, 2014 I'm going to have to start working earlier in the evening. cheers 3 Link to comment Share on other sites More sharing options...
Pete Posted August 9, 2014 Share Posted August 9, 2014 I'm going to have to start working earlier in the evening. So many times I've worked into the evenings and been stuck on an issue for hours. The answer almost always comes to me as I'm standing in the shower the next morning, then I look at the code (Data - haha) and do this: 2 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