您现在的位置是:首页 > cms教程 > phpcms教程phpcms教程

phpcms后台批量上传添加图片文章的方法

访旋2025-05-21phpcms教程已有人查阅

导读注:以下所有代码中,红色部分为增加部分。一、在后台增加批量添加按钮打开“phpcms\modules\content\templates\content_list.tpl.php”文件

注:以下所有代码中,红色部分为增加部分。
一、在后台增加批量添加按钮
打开“phpcms\modules\content\templates\content_list.tpl.php”文件
搜索
$category['catname']));?>
在这句话的后天的添加:
a echo="" href=":;" m="content&c=content&a=addall&menuid=&catid=&pc_hash=','')>
二、创建批量添加模板页
打开“phpcms\modules\content\templates\content_add.tpl.php”文件,将其全部另存为 “content_addall.tpl.php”文件,并将“content_addall.tpl.php”文件中的全部代码替换为如下代码:
!--?php
defined('IN_ADMIN') or exit('No permission resources.');$addbg=1;include $this->admin_tpl('header','admin');?>
< type="text/">
language="" type="text/" src="content_addtop.js">
language="" type="text/" src="colorpicker.js">
language="" type="text/" src="hotkeys.js">
language="" type="text/" src="cookie.js">
< type="text/">var catid=标题*缩略图src="swfupload/swf2ckeditor.js" type="text/">
< type="text/">function crop_cut_sdddd(id){
if (id=='') { alert('请先上传缩略图');return false;}
d.uploadfile();return false;}, function(){window.top.art.dialog({id:'crop'}).close()});};标题*缩略图src="swfupload/swf2ckeditor.js" type="text/">< type="text/">function crop_cut_sdddd(id){
if (id=='') { alert('请先上传缩略图');return false;}
d.uploadfile();return false;}, function(){window.top.art.dialog({id:'crop'}).close()});
};标题*缩略图src="swfupload/swf2ckeditor.js" type="text/">
< type="text/">function crop_cut_sdddd(id){if (id=='') { alert('请先上传缩略图');return false;}
d.uploadfile();return false;}, function(){window.top.art.dialog({id:'crop'}).close()});
};
标题*缩略图src="swfupload/swf2ckeditor.js" type="text/">< type="text/">function crop_cut_sdddd(id){
if (id=='') { alert('请先上传缩略图');return false;}
d.uploadfile();return false;}, function(){window.top.art.dialog({id:'crop'}).close()});
};
标题*缩略图src="swfupload/swf2ckeditor.js" type="text/">
< type="text/">function crop_cut_sdddd(id){
if (id=='') { alert('请先上传缩略图');return false;}
d.uploadfile();return false;}, function(){window.top.art.dialog({id:'crop'}).close()});
};
input name="info[catid]" type="hidden" value="" />
input class="cu" name="dosubmit" style="width:145px;" type="submit" value="" />
input class="cu" name="close" style="width:70px;" type="button" value="" />
< type="text/">
其中红色代码中的部分为批量添加的个数,具体根据实际情况而定,这里添加的是一次性添加5个图片,
三、添加接受批量添加数据函数addall()
打开“phpcms\modules\content\content.php”文件,搜索“public function add() ”函数,在该函数的后面添加以下代码:
public function addall() {
if(isset($_POST['dosubmit']) || isset($_POST['dosubmit_continue'])) {
define('INDEX_HTML',true);
$catid = $_POST['info']['catid'] = intval($_POST['info']['catid']);
if(trim($_POST['info']['01'])=='') showmessage(L('_is_empty'));
if(trim($_POST['info']['02'])=='') showmessage(L('_is_empty'));
if(trim($_POST['info']['03'])=='') showmessage(L('_is_empty'));
if(trim($_POST['info']['04'])=='') showmessage(L('_is_empty'));
if(trim($_POST['info']['05'])=='') showmessage(L('_is_empty'));
$01 = $_POST['info']['01'];
$02 = $_POST['info']['02'];
$03 = $_POST['info']['03'];
$04 = $_POST['info']['04'];
$05 = $_POST['info']['05'];
$suolve01 = $_POST['info']['suolve01'];
$suolve02 = $_POST['info']['suolve02'];
$suolve03 = $_POST['info']['suolve03'];
$suolve04 = $_POST['info']['suolve04'];
$suolve05 = $_POST['info']['suolve05'];
//print_r($_POST['info']);
$category = $this->categorys[$catid];
if($category['type']==0) {
$modelid = $this->categorys[$catid]['modelid'];
$this->db->set_model($modelid);
//如果该栏目设置了工作流,那么必须走工作流设定
$setting = string2array($category['setting']);
$workflowid = $setting['workflowid'];
if($workflowid && $_POST['status']!=99) {
//如果用户是超级管理员,那么则根据自己的设置来发布
$_POST['info']['status'] = $_SESSION['roleid']==1 ? intval($_POST['status']) : 1;
} else {
$_POST['info']['status'] = 99;
}
$this->db->addall_content($_POST['info']);
if(isset($_POST['dosubmit'])) {
showmessage(L('add_success').L('2s_close'),'blank','','','function set_time() {$("#secondid").html(1);}setTimeout("set_time()", 500);setTimeout("window.close()", 1200);');
} else {
showmessage(L('add_success'),HTTP_REFERER);
}
} else {
//单网页
$this->page_db = pc_::load_model('page_model');
$style_font_weight = $_POST['style_font_weight'] ? 'font-weight:'.strip_tags($_POST['style_font_weight']) : '';
$_POST['info']['style'] = strip_tags($_POST['style_color']).';'.$style_font_weight;
if($_POST['edit']) {
$this->page_db->update($_POST['info'],array('catid'=>$catid));
} else {
$catid = $this->page_db->insert($_POST['info'],1);
}
$this->page_db->create_html($catid,$_POST['info']);
$forward = HTTP_REFERER;
}
showmessage(L('add_success'),$forward);
} else {
$show_header = $show_dialog = $show_validator = '';
//设置cookie 在附件添加处调用
param::set_cookie('module', 'content');
if(isset($_GET['catid']) && $_GET['catid']) {
$catid = $_GET['catid'] = intval($_GET['catid']);
param::set_cookie('catid', $catid);
$category = $this->categorys[$catid];
if($category['type']==0) {
$modelid = $category['modelid'];
//取模型ID,依模型ID来生成对应的表单
require CACHE_MODEL_PATH.'content_form.class.php';
$content_form = new content_form($modelid,$catid,$this->categorys);
$forminfos = $content_form->get();
$formValidator = $content_form->formValidator;
$setting = string2array($category['setting']);
$workflowid = $setting['workflowid'];
$workflows = getcache('workflow_'.$this->siteid,'commons');
$workflows = $workflows[$workflowid];
$workflows_setting = string2array($workflows['setting']);
$nocheck_users = $workflows_setting['nocheck_users'];
$admin_username = param::get_cookie('admin_username');
if(!empty($nocheck_users) && in_array($admin_username, $nocheck_users)) {
$priv_status = true;
} else {
$priv_status = false;
}
include $this->admin_tpl('content_addall');
} else {
//单网页
$this->page_db = pc_::load_model('page_model');
$r = $this->page_db->get_one(array('catid'=>$catid));
if($r) {
extract($r);
$style_arr = explode(';',$style);
$style_color = $style_arr[0];
$style_font_weight = $style_arr[1] ? substr($style_arr[1],12) : '';
}
include $this->admin_tpl('content_page');
}
} else {
include $this->admin_tpl('content_addall');
}
header("Cache-control: private");
}
}
五、在图片模型中添加批量添加字段
进入网站后台---内容---模型管理--图片模型--字段管理,添加相应的批量添加字段,这里的字段值一定要和“content_addall.tpl.php”和“content.php”中的值一样,否则会出现错误,完成后效果如图所示:
六、将单条添加中的批量上传字段进行隐藏处理
为了能够达到更好的用户体验,需要将单条添加的时候,批量上传中用到的字段隐藏掉,打开“phpcms\modules\content \templates\content_add.tpl.php”文件,搜索“*”,在句话的上面增加判断。

本文标签:

很赞哦! ()

相关源码

  • (自适应响应式)黑色LED显示屏户外广告屏网站源码下载这是一款基于PbootCMS内核开发的响应式网站模板,专门为LED显示屏及户外广告行业打造。模板适配各类显示设备,帮助企业快速搭建专业官网,展示产品与服务优势,有效提升品牌形象。查看源码
  • 帝国cms7.5游戏门户H5小游戏网站模板源码免费下载基于帝国CMS7.5开发的H5游戏门户模板,为在线游戏平台设计。支持PC端与移动端同步生成,打造完整的游戏娱乐体验平台。查看源码
  • (自适应)蓝色英文外贸电子科技产品带三级栏目网站模板为外贸企业设计的英文网站模板,基于PbootCMS系统开发。突出多语言支持和国际化布局,三级栏目结构清晰展示产品分类,响应式设计确保更好客户在移动端和PC端获得一致的专业体验。查看源码
  • 帝国cms7.5模板生活常识美食女性时尚综合资讯门户源码本模板为帝国cms7.5生活资讯类网站设计,以天奇生活网为参考原型,涵盖生活常识、美食烹饪、女性时尚等多元化内容板块。采用响应式布局设计,适配各种终端设备,为访客提供优质的阅读体验。模板结构清晰合理,内容展示层次分明,符合生活类网站的用户需求。查看源码
  • (响应式)企业管理人力资源服务类pbootcms模板源码下载为人力资源服务及企业管理设计的响应式网站模板,基于PbootCMS内核开发。通过宽屏布局优化岗位展示效果,简洁界面聚焦人才服务核心业务,自适应技术确保在PC端与手机端查看源码
  • (自适应)家禽饲养养殖基地pbootcms模板响应式模板下载为家禽饲养企业、养殖基地设计的响应式网站模板,聚焦畜禽产品展示、养殖技术分享及企业信息服务。采用PbootCMS内核开发,响应式技术确保PC与手机端数据实时同步查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐