#yyds干货盘点# 织梦后台新增一个直播图文调用功能页面

Posted 是你的Sakura

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了#yyds干货盘点# 织梦后台新增一个直播图文调用功能页面相关的知识,希望对你有一定的参考价值。

我想在织梦的后台新增一个功能页面,是专门用来调用直播图文链接的,效果图如下:

#yyds干货盘点#

这样的话我在后台更改图片和加上直播链接,然后前台调用就可以啦~

想法有了,接下来开始分析,需要用到的东西。

需求:

1.需要图文两个需求

2.后台可更换生成

3.前端直接调用

分析:

既然我们已经知道所需的需求,我们就可以实施,考虑怎么利用后台已有的东西,去生成一个新的,我们可以使用的功能。

既然有图文和后台生成以及前端调用的需求,那我们就可以使用现有的文章发表功能,然后我们去更改一下它的页面和需求即可。

实施:

1.我们先新建一个文章页面,在标题栏里填写直播/你需求的链接地址,然后上传你所需调用的图片和所在的栏目,提交,记录下文章的id号,后面有用。

#yyds干货盘点#

2.进入你后台文件夹,你的后台文件夹可能已经更改了文件夹名,(开始基本上是dede或者admin,我们以admin文件夹为例)进入/admin/templets文件夹,搜寻找到index2.htm文件,打开然后搜索

<dd><a target="main" href="catalog_main.php"><i class="iconfont icon-menu"></i><cite>网站栏目管理</cite></a></dd>

在下面添加

<dd><a target="main" href="archives1_do.php?aid= 你记录下的文章id &dopost=editZibo"><i class="iconfont icon-menu"></i><cite>直播图片更改</cite></a></dd>

3.进入你后台文件夹,你的后台文件夹可能已经更改了文件夹名,(开始基本上是dede或者admin,我们以admin文件夹为例)进入admin文件夹,搜索寻找,里面如果有archives_do.php这个文件就说明找对了,我们需要做的是新建一个文件夹,叫 archives1_do.php,加入代码

require_once(dirname(__FILE__)./config.php);
require_once(DEDEADMIN./inc/inc_batchup.php);
require_once(DEDEADMIN./inc/inc_archives_functions.php);
require_once(DEDEINC./typelink.class.php);
require_once(DEDEINC./arc.archives.class.php);
$ENV_GOBACK_URL = (empty($_COOKIE[ENV_GOBACK_URL]) ? content_list.php : $_COOKIE[ENV_GOBACK_URL]);

if(empty($dopost))
{
layerMsg(对不起,你没指定运行参数!,-1,0);
exit();
}
$aid = isset($aid) ? preg_replace("#[^0-9]#", , $aid) : ;

/*--------------------------
//编辑直播文件
function editArchives(){ }
---------------------------*/
if($dopost==editZibo)
{
$query = "SELECT arc.id,arc.typeid,ch.maintable,ch.editcon
FROM `#@__arctiny` arc
LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
WHERE arc.id=$aid ";
$row = $dsql->GetOne($query);
$gurl = $row[editcon];
if($gurl==) $gurl=zibo_edit.php;
header("location:zibo_edit.php?aid=$aid");
exit();
}

?>

4.进入你后台文件夹,你的后台文件夹可能已经更改了文件夹名,(开始基本上是dede或者admin,我们以admin文件夹为例)进入/admin,搜索寻找,里面如果有archives_do.php这个文件就说明找对了(就上一步的同一目录下),我们需要做的是新建一个文件夹,叫 zibo_edit.php,加入代码

<?php

require_once(dirname(__FILE__)."/config.php");

CheckPurview(a_Edit,a_AccEdit,a_MyEdit);

require_once(DEDEINC."/customfields2.func.php");

require_once(DEDEADMIN."/inc/inc_archives_functions.php");

if(file_exists(DEDEDATA./template.rand.php))

{

require_once(DEDEDATA./template.rand.php);

}

if(empty($dopost)) $dopost = ;





$aid = isset($aid) && is_numeric($aid) ? $aid : 0;

if($dopost!=save)

{

require_once(DEDEADMIN."/inc/inc_catalog_options.php");

require_once(DEDEINC."/dedetag.class.php");

ClearMyAddon();



//读取归档信息

$query = "SELECT ch.typename AS channelname,ar.membername AS rankname,arc.*

FROM `#@__archives` arc

LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel

LEFT JOIN `#@__arcrank` ar ON ar.rank=arc.arcrank WHERE arc.id=$aid ";

$arcRow = $dsql->GetOne($query);

if(!is_array($arcRow))

{

ShowMsg("读取档案基本信息出错!","-1");

exit();

}

$query = "SELECT * FROM `#@__channeltype` WHERE id=".$arcRow[channel]."";

$cInfos = $dsql->GetOne($query);

if(!is_array($cInfos))

{

ShowMsg("读取频道配置信息出错!","javascript:;");

exit();

}

$addtable = $cInfos[addtable];

$addRow = $dsql->GetOne("SELECT * FROM `$addtable` WHERE aid=$aid");

if(!is_array($addRow))

{

ShowMsg("读取附加信息出错!","javascript:;");

exit();

}

$channelid = $arcRow[channel];

$tags = GetTags($aid);

include DedeInclude("templets/zhibo_edit.htm");

exit();

}

/*--------------------------------

function __save(){ }

-------------------------------*/

else if($dopost==save)

{

require_once(DEDEINC./image.func.php);

require_once(DEDEINC./oxwindow.class.php);

$flag = isset($flags) ? join(,,$flags) : ;

$notpost = isset($notpost) && $notpost == 1 ? 1: 0;



if(empty($typeid2)) $typeid2 = 0;

if(!isset($autokey)) $autokey = 0;

if(!isset($remote)) $remote = 0;

if(!isset($dellink)) $dellink = 0;

if(!isset($autolitpic)) $autolitpic = 0;



if(empty($typeid))

{

ShowMsg("请指定文档的栏目!", "-1");

exit();

}

if(empty($channelid))

{

ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!", "-1");

exit();

}

if(!CheckChannel($typeid, $channelid))

{

ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!", "-1");

exit();

}

if(!TestPurview(a_Edit))

{

if(TestPurview(a_AccEdit))

{

CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的文档权限!");

}

else

{

CheckArcAdmin($id, $cuserLogin->getUserID());

}

}





//对保存的内容进行处理

$pubdate = GetMkTime($pubdate);

$sortrank = AddDay($pubdate,$sortup);

$ismake = $ishtml==0 ? -1 : 0;

$autokey = 1;

$title = dede_htmlspecialchars(cn_substrR($title,$cfg_title_maxlen));

$shorttitle = cn_substrR($shorttitle,36);

$color = cn_substrR($color,7);

$writer = cn_substrR($writer,20);

$source = cn_substrR($source,30);

$description = cn_substrR($description,250);

$keywords = trim(cn_substrR($keywords,60));

$filename = trim(cn_substrR($filename,40));

$isremote = (empty($isremote)? 0 : $isremote);

$serviterm=empty($serviterm)? "" : $serviterm;

if(!TestPurview(a_Check,a_AccCheck,a_MyCheck))

{

$arcrank = -1;

}

$adminid = $cuserLogin->getUserID();



//处理上传的缩略图

if(empty($ddisremote))

{

$ddisremote = 0;

}

$litpic = GetDDImage(none,$picname,$ddisremote);



//分析body里的内容

$body = AnalyseHtmlBody($body,$description,$litpic,$keywords,htmltext);



//分析处理附加表数据

$inadd_f = ;

$inadd_v = ;

if(!empty($dede_addonfields))

{

$addonfields = explode(;,$dede_addonfields);

$inadd_f = ;

$inadd_v = ;

if(is_array($addonfields))

{

foreach($addonfields as $v)

{

if($v==)

{

continue;

}

$vs = explode(,,$v);

if($vs[1]==htmltext||$vs[1]==textdata) //HTML文本特殊处理

{

${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$litpic,$keywords,$vs[1]);

}else

{

if(!isset(${$vs[0]}))

{

${$vs[0]} = ;

}

${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$id);

}

$inadd_f .= ",`{$vs[0]}` = ".${$vs[0]}."";

}

}

}



//处理图片文档的自定义属性

if($litpic!= && !preg_match("#p#", $flag))

{

$flag = ($flag== ? p : $flag.,p);

}

if($redirecturl!= && !preg_match("#j#", $flag))

{

$flag = ($flag== ? j : $flag.,j);

}



//跳转网址的文档强制为动态

if(preg_match("#j#", $flag)) $ismake = -1;

//更新数据库的SQL语句

$query = "UPDATE #@__archives SET

typeid=$typeid,

typeid2=$typeid2,

sortrank=$sortrank,

flag=$flag,

click=$click,

ismake=$ismake,

arcrank=$arcrank,

money=$money,

title=$title,

color=$color,

writer=$writer,

source=$source,

litpic=$litpic,

voteid=$voteid,

notpost=$notpost,

description=$description,

keywords=$keywords,

shorttitle=$shorttitle,

filename=$filename,

dutyadmin=$adminid,

weight=$weight

WHERE id=$id; ";



if(!$dsql->ExecuteNoneQuery($query))

{

ShowMsg(更新数据库archives表时出错,请检查,-1);

exit();

}



$cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id=$channelid ");

$addtable = trim($cts[addtable]);

if($addtable!=)

{

$useip = GetIP();

$templet = empty($templet) ? : $templet;

$iquery = "UPDATE `$addtable` SET typeid=$typeid,body=$body{$inadd_f},redirecturl=$redirecturl,templet=$templet,userip=$useip WHERE aid=$id";

if(!$dsql->ExecuteNoneQuery($iquery))

{

ShowMsg("更新附加表 `$addtable` 时出错,请检查原因!","javascript:;");

exit();

}

}



//生成HTML

UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);

if($cfg_remote_site==Y && $isremote=="1")

{

if($serviterm!=""){

list($servurl, $servuser, $servpwd) = explode(,, $serviterm);

$config=array( hostname => $servurl, username => $servuser,

password => $servpwd,debug => TRUE);

} else {

$config=array();

}

if(!$ftp->connect($config)) exit(Error:None FTP Connection!);

}

$artUrl = MakeArt($id,true,true,$isremote);

if($artUrl==)

{

$artUrl = $cfg_phpurl."/view.php?aid=$id";

}

ClearMyAddon($id, $title);



//返回成功信息

$msg = "

  请选择你的后续操作:

<a href=article_add.php?cid=$typeid><u>发布新文章</u></a>

&nbsp;&nbsp;

<a href=archives1_do.php?aid=".$id."&dopost=editZibo><u>查看更改</u></a>

&nbsp;&nbsp;

<a href=$artUrl target=_blank><u>查看文章</u></a>

&nbsp;&nbsp;

<a href=catalog_do.php?cid=$typeid&dopost=listArchives><u>管理文章</u></a>

&nbsp;&nbsp;

$backurl

";



$wintitle = "成功更改直播管理!";

$wecome_info = "更改直播链接页面";

$win = new OxWindow();

$win->AddTitle("成功更改直播链接:");

$win->AddMsgItem($msg);

$winform = $win->GetWindow("hand","&nbsp;",false);

$win->Display();

}

5.进入你后台文件夹,你的后台文件夹可能已经更改了文件夹名,(开始基本上是dede或者admin,我们以admin文件夹为例)进入/admin/templets文件夹,搜寻找到article_edit.htm文件,因为我们是仿照它做的页面,所以能找到它就说明我们的文件夹进入正确,然后在当前文件夹下新建zhibo_edit.htm,加入代码,保存

<!DOCTYPE html>

<html>

<head>

<meta charset="<?php echo $cfg_soft_lang; ?>">

<title><?php echo $cfg_softname; ?></title>

<meta name="renderer" content="webkit">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<meta name="apple-mobile-web-app-status-bar-style" content="black">

<meta name="apple-mobile-web-app-capable" content="yes">

<meta name="format-detection" content="telephone=no">

<link rel="stylesheet" href="../publics/layui/css/layui.css" media="all" />

<link rel="stylesheet" href="../publics/iconfont/iconfont.css" media="all" />

<link rel="stylesheet" href="css/admin.css" media="all" />

<link href=css/tb-box.css rel=stylesheet type=text/css />

<script language="javascript" src="js/dedeajax2.js"></script>

<script language="javascript" src="js/main.js"></script>

<script type="text/javascript"src="js/handlers.js"></script>

<script type="text/javascript" src="../images/swfupload/swfupload.js"></script>

<script language="javascript" src="js/jquery/jquery.js"></script>

<script language="javascript" src="js/jquery/ui.core.js"></script>

<script language="javascript" src="js/jquery/ui.draggable.js"></script>

<script language=javascript src=js/tb-box.js></script>

<script language="javascript">

<!--

var swfu = null;

var arctype = article;

function checkSubmit()

{

if(document.form1.title.value==)

{

alert(直播链接不能为空!);

document.form1.title.focus();

return false;

}

}



function addVote()

{

tb_show(添加投票, vote_add.php?isarc=1&TB_iframe=true&height=460&width=600, false);

}



function selectVote()

{

tb_show(选取投票,vote_main.php?issel=1&TB_iframe=true&height=460&width=600,false);

}





function viewVote()

{

if($("#voteid").val() != 0)

{

window.open(<?php echo $cfg_cmsurl;?>/plus/vote.php?dopost=view&aid= + $("#voteid").val());

} else {

alert(请选择一个投票);

return false;

}

}

window.onload = function ()

{

swfu = new SWFUpload(

{

// Backend Settings

upload_url: "swfupload.php",

post_params: {"PHPSESSID": "<?php echo session_id(); ?>", "dopost" : "", "arctype" : arctype,

"arcid":<?php echo $arcRow[id]?>},



// File Upload Settings

file_size_limit : "2 MB", // 2MB

file_types : "*.jpg; *.gif; *.png",

file_types_description : "选择 JPEG/GIF/PNG 格式图片",

file_upload_limit : "0",



file_queue_error_handler : fileQueueError,

file_dialog_complete_handler : fileDialogComplete,

upload_progress_handler : uploadProgress,

upload_error_handler : uploadError,

upload_success_handler : uploadSuccess,

upload_complete_handler : uploadComplete,



button_image_url : "../images/SmallSpyGlassWithTransperancy_17x18.png",

button_placeholder_id : "spanButtonPlaceholder",

button_width: 100%,

button_height: 26,

button_text : <div class="button" style="background-color:#E5F1CF; height:26px; text-align:center; line-height:26px">上传图片(可多选)</div>,

button_text_style : ,

button_text_top_padding: 0,

button_text_left_padding: 10,

button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,

button_cursor: SWFUpload.CURSOR.HAND,



// Flash Settings

flash_url : "../images/swfupload/swfupload.swf",



custom_settings : {

upload_target : "divFileProgressContainer"

},



// Debug Settings

debug: false

});

};



function addtoEditOld(picurl,pid)

{

var picTitle = jQuery(input[name="picinfook+pid+"]).val();

var picHTML = <img src="+picurl+" />;

CKEDITOR.instances.body.insertHtml(picHTML);

}



//删除已经上传的图片

function delAlbPic(pid){

// 同步删除编辑器中插入的图片

jQuery("#__tmpbody").html();

jQuery.get(swfupload.php?dopost=addtoedit&id= + pid, function(data)

{

var iptbody = CKEDITOR.instances.body.getData();

jQuery("#__tmpbody").html(iptbody);

jQuery("#__tmpbody").find(img).each(function()

{

if(jQuery(this).attr(src) == data)

{

//alert(data);

jQuery(this).remove();

}

});

CKEDITOR.instances.body.setData(jQuery("#__tmpbody").html());

jQuery("#__tmpbody").html();

var tgobj = $Obj(albCtok+pid);

var myajax = new DedeAjax(tgobj);

myajax.SendGet2(swfupload.php?dopost=del&id=+pid);

$Obj(thumbnails).removeChild(tgobj);

});

}



function addtoEdit(pid)

{

jQuery.get(swfupload.php?dopost=addtoedit&id= + pid, function(data)

{

var picTitle = jQuery(input[name="picinfook+pid+"]).val();

var picHTML = <img src="+data+" />;

CKEDITOR.instances.body.insertHtml(picHTML);

});

}



//删除已经上传的图片(编辑时用)

function delAlbPicOld(picfile, pid){

var iptbody = CKEDITOR.instances.body.getData();

jQuery("#__tmpbody").html(iptbody);

jQuery("#__tmpbody").find(img).each(function()

{

if(jQuery(this).attr(src) == picfile)

{

//alert(data);

jQuery(this).remove();

}

});

CKEDITOR.instances.body.setData(jQuery("#__tmpbody").html());

jQuery("#__tmpbody").html();



var tgobj = $Obj(albold+pid);

var myajax = new DedeAjax(tgobj);

myajax.SendGet2(swfupload.php?dopost=delold&picfile=+picfile);

$Obj(thumbnailsEdit).removeChild(tgobj);

}

-->

</script>

</head>

<body class="childrenBody">

<div class="x-nav">

<span class="layui-breadcrumb">

<a href="catalog_do.php?cid=2&channelid=<?php echo $channelid?>&dopost=listArchives">编辑直播页面</a>


</span>

<a class="layui-btn layui-btn-small refresh" href="javascript:location.replace(location.href);" title="刷新"><i class="iconfont icon-refresh" style="line-height:30px"></i></a>

</div>

<form name="form1" action="zibo_edit.php" enctype="multipart/form-data" method="post" class="layui-form layui-form-pane layui-mt-10">

<input type="hidden" name="dopost" value="save" />

<input type="hidden" name="channelid" value="<?php echo $channelid?>" />

<input type="hidden" name="id" value="<?php echo $aid?>" />

<div class="layui-form-item">

<div class="layui-inline">

<label class="layui-form-label">直播链接</label>

<div class="layui-input-inline" style="width:450px;">

<input name="title" id="title" type="text" class="layui-input" lay-verify="title" placeholder="请输入直播链接" value="<?php echo $arcRow[title]; ?>">

</div>

</div>

</div>

<div class="layui-form-item">

<div class="layui-inline">

<label class="layui-form-label">直 播 图</label>

<div class="layui-input-block">
<input name="picname" type="text" id="picname" class="layui-input" style="float:left;margin-right:-2px;width:300px;" value="<?php echo $arcRow["litpic"]?>">
<input type="button" value="本地上传" class="layui-btn" />
<iframe name=uplitpicfra id=uplitpicfra src= width=200 height=200 style=display:none></iframe>
<span class="litpic_span"><input name="litpic" type="file" id="litpic" onchange="SeePicNew(this, divpicview, uplitpicfra, 165, article_edit.php);delDisabled(litpic)" size="1" class="np coolbg"></span>
<input type="button" name="Submit2" value="站内选择" onClick="SelectImage(form1.picname,small);" class="layui-btn layui-btn-normal"/>
</div>

</div>

<div class="layui-inline">
更改后:<div id=divpicview class=divpre></div>
更改前:<div><img src="<?php if($arcRow["litpic"]!="") echo $arcRow["litpic"]; else echo "images/pview.gif";?>" id="picview" name="picview"></div>

</div>

</div>

<div class="layui-form-item">

<div class="layui-inline">

<label class="layui-form-label">文章主栏目</label>

<div class="layui-input-inline">

<span id=typeidct>

<?php

$typeOptions = GetOptionList($arcRow[typeid],$cuserLogin->getUserChannel(),$channelid);

echo "<select name=typeid id=typeid style=width:240px>\\r\\n";

if($arcRow["typeid"]=="0") echo "<option value=0 selected>请选择栏目...</option>\\r\\n";

echo $typeOptions;

echo "</select>";

?>

</span>

</div>

<div class="layui-form-mid layui-word-aux">

<img src=images/menusearch.gif style=cursor:pointer; onClick="ShowCatMap(event, this, <?php echo $channelid; ?>, typeid, <?php echo $arcRow[typeid]; ?>)" alt=快捷选择 title=快捷选择 />

<?php

if($cfg_remote_site==Y)

{

?>

<input name="isremote" type="checkbox" id="isremote" value="1" <?php if($cfg_title_site==Y) echo "checked";?> lay-ignore>

是否同步远程发布

<?php GetFtp();?>

<?php

}

?>

</div>

</div>

</div>
<div class="layui-form-item">

<div class="layui-input-block">

<button class="layui-btn">提交保存</button>

<button type="reset" class="layui-btn layui-btn-danger">重置</button>

<a class="layui-btn layui-btn-primary" href="javascript:;" onClick=history.go(-1);>返回</a>

</div>

</div>

</form>

<script language=javascript>InitPage();</script>

<div id="__tmpbody" style="display:none"></div>

<script type="text/javascript" src="../publics/layui/layui.js"></script>

<script type="text/javascript" src="js/alllist.js"></script>

</body>

</html>

然后大功告成!进入后台看一下

#yyds干货盘点#

栏目管理中就新增了直播页面的栏目,前台调用代码

{dede:arclist row=1 titlelen=240 orderby=pubdate idlist=文章id}
<div style="margin-top: 24px;">
<a href="[field:title/]" class="play-video" data-animate="zoomIn" data-duration="1.5s" data-delay="0.1s"><img src="[field:litpic/]" ></a>
</div>
{/dede:arclist}

总结:

利用现有的文章页面来调用已新增的文章做为直播需求页面,然后记录下文章ID,自写一套该页面调用更改的方法。


以上是关于#yyds干货盘点# 织梦后台新增一个直播图文调用功能页面的主要内容,如果未能解决你的问题,请参考以下文章

#yyds干货盘点# 织梦微信分享开发

#yyds干货盘点# 织梦根据TAG标签来搜索展示相关文章

Flutter 找不到 android sdk(图文详解) #yyds干货盘点#

#yyds干货盘点#-设计模式分享-组合模式

#yyds干货盘点#kvm新增盘给home扩大空间

#yyds干货盘点#愚公系列2022年11月 微信小程序-实时音视频录制