日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

content add tpl.php,phpcms后台批量上传添加图片文章方法详解(一)

發布時間:2023/12/10 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 content add tpl.php,phpcms后台批量上传添加图片文章方法详解(一) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

注:以下所有代碼中,紅色部分為增加部分。

一、在后臺增加批量添加按鈕

打開“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 functionaddall() {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”文件,搜索“*”,在句話的上面增加判斷,效果圖下圖:

原文:http://www.cnblogs.com/zjy954/p/5526332.html

總結

以上是生活随笔為你收集整理的content add tpl.php,phpcms后台批量上传添加图片文章方法详解(一)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。