Peter Knight Posted December 31, 2024 Share Posted December 31, 2024 Hi I’m trying to find an up to date tutorial on enabling remote page creation via API? I’m building a localhost tool / project and want to use that to create new pages in a target site. I can find lots of API docs but unsure of the first steps on target site. Thanks Link to comment Share on other sites More sharing options...
breezer Posted December 31, 2024 Share Posted December 31, 2024 I use the following to create pages via API. I don't know how you have your setup, but you can add the code to a front end template in the content section so you can see the results printed. /* page: status 9 - published (default) 13 - locked / not editable 1033 - hidden 2057 - unpublished 3081 - hidden / unpublished template_id,parent_id,page_status,page_name,page_title,install_description */ $_SESSION['install_log'] =array(); $newp = array( '1,1,9,account2,Account2,User account', '1,1,9,profile2,Profile2,User profile', '1,1,9,register2,Register2,New registration', '1,1,9,tos2,Terms of Service2,Terms of Service', '1,1,9,search2,Search2,Forum search', '1,1,9,banned2,Banned2,Banned user landing page', '1,1,9,help2,Help2,Forum help' ); foreach($newp as $r){ $q =explode(',',$r); $p = new Page(); $p->template = trim($q[0]); $p->parent = trim($q[1]); $p->status =trim($q[2]); $p->name = trim($q[3]); $p->title = trim($q[4]); if($p->save()){ $_SESSION['install_log']['document_create'][$p->title]['id'] = $p->id; $status ='success'; }else{ $status ='failure'; } $_SESSION['install_log']['document_create'][$p->title]['status'] =$status; $_SESSION['install_log']['document_create'][$p->title]['description'] =$q[5]; } function print_array( $data ){ $text =print_r( $data, TRUE ); return '<pre style="font-size:15px; line-height:16px;">'.$text.'</pre>'; } echo print_array($_SESSION['install_log']); 2 Link to comment Share on other sites More sharing options...
breezer Posted Wednesday at 05:52 AM Share Posted Wednesday at 05:52 AM I'm sorry I think I was sleep deprived and misunderstood when I read your post, so maybe this is what you were looking for: Sorry and hope this helps 🙂 Link to comment Share on other sites More sharing options...
Peter Knight Posted Wednesday at 01:22 PM Author Share Posted Wednesday at 01:22 PM Thanks @breezerThat first answer was a big help. 1 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