当前位置:Gxlcms > PHP教程 > PHPCMS如下代码,想在指定位置调用content模块content控制器下的add()方法提交数据,如何实现?

PHPCMS如下代码,想在指定位置调用content模块content控制器下的add()方法提交数据,如何实现?

时间:2021-07-01 10:21:17 帮助过:3人阅读


如图所示,由其它页面提交$_POST['info']文章数据到当前页面,进行权限和栏目的验证或判断后,使用content控制器的add方法提交到数据库?请问应该怎样写?

回复内容:


如图所示,由其它页面提交$_POST['info']文章数据到当前页面,进行权限和栏目的验证或判断后,使用content控制器的add方法提交到数据库?请问应该怎样写?

  1. <code>//$siteid=1;
  2. //$categorys = getcache('category_content_'.$siteid,'commons'); //缓存文件
  3. pc_base::load_model('content_model'); //加载内容模型
  4. $add_content = new content_model(); //
  5. $modelid = $categorys[$catid]['modelid']; //获得模型id
  6. $add_content->set_model($modelid); //初始化
  7. $add_content->add_content($info); //$info提交的内容</code>

人气教程排行