Public Function Actionchangetemplate () {$status =true; $interactive _id= (int) filter_input (input_post, ' id '),//post[id] $template _id= (int) filter_input (input_post , ' MB '); Find page $interactives = Interactives::model ()->findbypk ($interactive _id);//get template $interactivetemplate = Interactivetemplate::model ()->findbypk ($template _id);//modify Template $interactives->template_id = $template _id; $interactives->save ();//Set different content according to the template selected by the user $template_info = $interactiveTemplate->template_content;$ Interactivecontent = new Interactivecontent (); $interactivePic = new Interactivepic (); Add content, following regular expression matching based on content, generating corresponding contentif (Preg_match_all ('/preview_t_[0-9]+/', $template _info, $arr)) {//delete $res = Interactivecontent::model ()->deleteall ("Interactive_id=:id", Array (": id" = = $interactive _id)); foreach ($arr [0] as $key = $value) {$content = new interactivecontent (); $content->interactive_id = $interactive _id; $content-≫color = "Rgba (0,0,0,0.1)"; $content->content = ' \n\t text input box <\/strong><\/span>\n<\/p>\n
\n\tYou can make text input, copy, paste, adjust font size, color, alignment, line spacing, or you can set the corresponding background color and transparency for the text box itself. <\/span>\n<\/p> '; $content->c_time = Date ("y-m-d h:i:s"); $ret = $content->save (); if ($ret >0)//If correct, the result is true $status = $status &true; else $status = $status &false;}} Add Picture if (Preg_match_all ('/preview_p_[0-9]+/', $template _info, $arr)) {//delete $res = Interactivepic::m Odel ()->deleteall ("Interactive_id=:id", Array (": id" =>$_post [' ID '])), for ($i = 1; $i <= count ($arr [0]); $i + + {$interactivePic = new Interactivepic (), $interactivePic->interactive_id = $_post [' id ']; $interactivePic->pic_ Scale = 2.2; $interactivePic->pic_src = "/images/editinteractive/pcover_000.jpg"; $interactivePic->pic_width = $interactivePic->pic_height =30, $interactivePic->pic_x = 0; $interactivePic->pic_y =0; $interactivePic- >tag = $i; $interactivePic->c_time = Date ("y-m-d h:i:s");$ret = $interactivePic->save (); if ($ret >0)//If correct, the result is true $status = $status &true; else $status = $status &false;}} if (Preg_match_all ('/preview_s1_1_p[0-9]+/', $template _info, $arr)) {//Remove $res = Interactivepic::model () DeleteAll ("Interactive_id=:id", Array (": id" =>$_post [' ID '])), for ($i = 1; $i <= count ($arr [0]); $i + +) {$interact Ivepic = new Interactivepic (), $interactivePic->interactive_id = $_post [' id ']; $interactivePic->pic_scale = 2.2;$ INTERACTIVEPIC->PIC_SRC = "/images/editinteractive/pcover_000.jpg"; $interactivePic->pic_width = 33;$ Interactivepic->pic_height =44, $interactivePic->pic_x = $interactivePic->pic_y =44; $interactivePic- >tag = $interactivePic->c_time = Date ("y-m-d h:i:s"), $ret = $interactivePic->save (); if ($ret >0)//If correct, the result is true $status = $status &true; else $status = $status &false;}} if (Preg_match_all ('/preview_s1_1_t[0-9]+/', $template _info, $arr)) {//Remove $res = Interactivecontent::model () DeleteAll ("Interactive_id=:id", Array (": id" =>$_post [' ID '])); foreach ($arr [0] as $key = = $value) {$content = new Interactivecontent (); $content->interactive_id = $_post [' id ']; $content->color = "Rgba (0,0,0,0.1)"; $content- >content = '
\n\t text input box <\/strong><\/span>\n<\/p>\n
\n\t You can text input, copy, paste, adjust font size, color, alignment, line spacing, or you can set the corresponding background color and transparency of the text box itself. <\/span>\n<\/p> '; $content->c_time = Date ("y-m-d h:i:s"); $ret = $content->save (); if ($ret >0)//If correct, the result is true $status = $status &true; else $status = $status &false;}} if (Preg_match_all ('/preview_s1_1_t_[0-9]+/', $template _info, $arr)) {//Remove $res = Interactivecontent::model () DeleteAll ("Interactive_id=:id", Array (": id" =>$_post [' ID '])); foreach ($arr [0] as $key = = $value) {$content = new Interactivecontent (); $content->interactive_id = $_post [' id ']; $content->color = "Rgba (0,0,0,0.1)"; $content- >content = '
\n\t text input box <\/strong><\/span>\n<\/p>\n
\n\t You can text input, copy, paste, adjust font size, color, alignment, line spacing, or you can set the corresponding background color and transparency of the text box itself. <\/span>\n<\/p> '; $content->c_time = Date ("y-m-d h:i:s"); $ret = $content->save (); if ($ret >0)//If correct, the result is true $status = $status &true; else $status = $status &false;}} if ($status) {echo json_encode (array (//success ' status ' = ' success '));} else {echo json_encode (' status ' = > ' fail ');}}
The above describes the get template functions, including aspects of the content, you want to be interested in PHP tutorial friends helpful.