eyoucms文章添加指定关联文章
时间:2023年12月19日
/来源:网络
/编辑:佚名
围绕eyoucms预留了关联字段joinaid,绑定文章关联
在application\admin\controller\DiyExtend.php添加自定义控制方法
//选择学校
public function select_school()
{
$condition = array();
// 获取到所有GET参数
$param = input('param.');
$typeid = input('typeid/d', 0);
// 模型ID
$condition['a.channel'] = array('eq', 101);
// 应用搜索条件
foreach (['keywords','typeid'] as $key) {
if (isset($param[$key]) && $param[$key] !== '') {
if ($key == 'keywords') {
$condition['a.title'] = array('LIKE', "%{$param[$key]}%");
} else if ($key == 'typeid') {
$typeid = $param[$key];
$hasRow = model('Arctype')->getHasChildren($typeid);
$typeids = get_arr_column($hasRow, 'id');
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
if(isset($auth_role_info['only_oneself']) && 1 == $auth_role_info['only_oneself']){
$condition['a.admin_id'] = $admin_info['admin_id'];
}
if(! empty($auth_role_info['permission']['arctype'])){
if (!empty($typeid)) {
$typeids = array_intersect($typeids, $auth_role_info['permission']['arctype']);
}
}
}
}
/*--end*/
$condition['a.typeid'] = array('IN', $typeids);
} else {
$condition['a.'.$key] = array('eq', $param[$key]);
}
}
}
// 多语言
$condition['a.lang'] = array('eq', $this->admin_lang);
$count = DB::name('archives')->alias('a')->where($condition)->count('aid');// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = DB::name('archives')
->field("a.aid,a.title")
->alias('a')
->where($condition)
->order('sort_order asc, aid desc')
->limit($Page->firstRow.','.$Page->listRows)
->select();
$pageStr = $Page->show();// 分页显示输出
$this->assign('pageStr',$pageStr);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->assign('pager',$Page);// 赋值分页对象
return $this->fetch();
}
第二步、后台文章页修改自定义扩展模板文件新建select_school.htm,目录application\admin\template\diy_extend\select_school.htm
{include file="public/layout" /}
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit; min-width: auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page ad" style="min-width: auto;">
<div class="flexigrid">
<div class="mDiv">
<form class="navbar-form form-inline" action="{:url('DiyExtend/select_school')}" method="get" onSubmit="layer_loading('正在处理');">
{$searchform.hidden|default=''}
<div class="sDiv">
<div class="sDiv2">
<input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="名称搜索...">
<input type="submit" class="btn" value="搜索">
<i class="fa fa-search"></i>
</div>
</div>
</form>
</div>
<div class="hDiv">
<div class="hDivBox">
<table cellspacing="0" cellpadding="0" style="width: 100%">
<thead>
<tr>
<th abbr="article_title" axis="col3" class="w60">
<div class="tc">ID</div>
</th>
<th abbr="article_title" axis="col3" class="">
<div class="">学校名称</div>
</th>
<th axis="col1" class="w60">
<div class="tc">操作</div>
</th>
</tr>
</thead>
</table>
</div>
</div>
<div class="bDiv" style="height: auto;">
<div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
<table style="width: 100%;">
<tbody>
{empty name="list"}
<tr>
<td class="no-data" align="center" axis="col0" colspan="50">
<i class="fa fa-exclamation-circle"></i>没有符合条件的数据
</td>
</tr>
{else/}
{foreach name="list" item="vo" key="k" }
<tr>
<td class="sort">
<div class="tc w60">
{$vo.aid}
</div>
</td>
<td style="width: 100%;">
<div class="">{$vo.title}</div>
</td>
<td>
<div class="w60 tc">
<input type="hidden" name="aid" id="aid_{$vo.aid}" data-aid="{$vo.aid}" data-title="{$vo.title}" />
<a class="btn blue" href="javascript:void(0);" onClick="select_arc({$vo.aid});"><i class="fa fa-location-arrow"></i>选择</a>
</div>
</td>
</tr>
{/foreach}
{/empty}
</tbody>
</table>
</div>
<div class="iDiv" style="display: none;"></div>
</div>
<div class="tDiv">
<div class="tDiv2">
{include file="public/page" /}
</div>
<div style="clear:both"></div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
// 表格行点击选中切换
$('#flexigrid > table>tbody >tr').click(function(){
$(this).toggleClass('trSelected');
});
// 点击刷新数据
$('.fa-refresh').click(function(){
location.href = location.href;
});
});
// 文档对象
function ArcItem(aid, title) {
this.aid = aid;
this.title = title;
}
function select_arc(aid)
{
var input = $('#aid_'+aid);
var arcItem = null;
arcItem = new ArcItem(input.data('aid'), input.data('title'));
window.parent.sjs_call_back(arcItem);
}
</script>
{include file="public/footer" /}
第三步修改默认的自定义模板application\admin\template\diy_extend\archives_extend.htm
<!-- 用户自定义扩展模板文件,仅用于文档的新增和编辑页面 -->
{php}
// 这里可以实现原生php代码
$diyExtendLogic = new \app\admin\logic\DiyExtendLogic;
{/php}
<!-- 这里自定义HTML表单代码 -->
{if in_array($params.channeltype, [3,10])}
<dl class="row">
<dt class="tit">
<label>学校</label>
</dt>
<dd class="opt">
<span id="sjs_title">{$field.joinaid|getArchivesField=###,'title'}</span>
<input type="hidden" name="joinaid" id="joinaid" value="{$field.joinaid}">
<a href="javascript:void(0);" onclick="diy_select_school(this);" class="ncap-btn ncap-btn-green">学校列表</a>
<span class="err"></span>
<p class="notic"></p>
</dd>
</dl>
<script type="text/javascript">
function diy_select_school(obj)
{
//iframe窗
layer.open({
type: 2,
title: '学校列表',
fixed: true, //不固定
shadeClose: false,
shade: 0.3,
maxmin: true, //开启最大化最小化按钮
area: ['600px', '500px'],
content: "{:url('DiyExtend/select_school')}"
});
}
function sjs_call_back(arcItem)
{
$('#sjs_title').html(arcItem.title);
$('#joinaid').val(arcItem.aid);
layer.closeAll('iframe');
}
</script>
{/if}
效果图如下:
eyoucms文章添加指定关联文章-第1张图片-九零博客 - 一个分享技术、记录生活的个人技术博客
列表调用方法
{eyou:arcview joinaid='$field.joinaid' id='field2'}
<a href="{$field2.arcurl}">{$field2.title}</a>
{/eyou:arcview}
在application\admin\controller\DiyExtend.php添加自定义控制方法
//选择学校
public function select_school()
{
$condition = array();
// 获取到所有GET参数
$param = input('param.');
$typeid = input('typeid/d', 0);
// 模型ID
$condition['a.channel'] = array('eq', 101);
// 应用搜索条件
foreach (['keywords','typeid'] as $key) {
if (isset($param[$key]) && $param[$key] !== '') {
if ($key == 'keywords') {
$condition['a.title'] = array('LIKE', "%{$param[$key]}%");
} else if ($key == 'typeid') {
$typeid = $param[$key];
$hasRow = model('Arctype')->getHasChildren($typeid);
$typeids = get_arr_column($hasRow, 'id');
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
if(isset($auth_role_info['only_oneself']) && 1 == $auth_role_info['only_oneself']){
$condition['a.admin_id'] = $admin_info['admin_id'];
}
if(! empty($auth_role_info['permission']['arctype'])){
if (!empty($typeid)) {
$typeids = array_intersect($typeids, $auth_role_info['permission']['arctype']);
}
}
}
}
/*--end*/
$condition['a.typeid'] = array('IN', $typeids);
} else {
$condition['a.'.$key] = array('eq', $param[$key]);
}
}
}
// 多语言
$condition['a.lang'] = array('eq', $this->admin_lang);
$count = DB::name('archives')->alias('a')->where($condition)->count('aid');// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = DB::name('archives')
->field("a.aid,a.title")
->alias('a')
->where($condition)
->order('sort_order asc, aid desc')
->limit($Page->firstRow.','.$Page->listRows)
->select();
$pageStr = $Page->show();// 分页显示输出
$this->assign('pageStr',$pageStr);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->assign('pager',$Page);// 赋值分页对象
return $this->fetch();
}
第二步、后台文章页修改自定义扩展模板文件新建select_school.htm,目录application\admin\template\diy_extend\select_school.htm
{include file="public/layout" /}
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit; min-width: auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page ad" style="min-width: auto;">
<div class="flexigrid">
<div class="mDiv">
<form class="navbar-form form-inline" action="{:url('DiyExtend/select_school')}" method="get" onSubmit="layer_loading('正在处理');">
{$searchform.hidden|default=''}
<div class="sDiv">
<div class="sDiv2">
<input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="名称搜索...">
<input type="submit" class="btn" value="搜索">
<i class="fa fa-search"></i>
</div>
</div>
</form>
</div>
<div class="hDiv">
<div class="hDivBox">
<table cellspacing="0" cellpadding="0" style="width: 100%">
<thead>
<tr>
<th abbr="article_title" axis="col3" class="w60">
<div class="tc">ID</div>
</th>
<th abbr="article_title" axis="col3" class="">
<div class="">学校名称</div>
</th>
<th axis="col1" class="w60">
<div class="tc">操作</div>
</th>
</tr>
</thead>
</table>
</div>
</div>
<div class="bDiv" style="height: auto;">
<div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
<table style="width: 100%;">
<tbody>
{empty name="list"}
<tr>
<td class="no-data" align="center" axis="col0" colspan="50">
<i class="fa fa-exclamation-circle"></i>没有符合条件的数据
</td>
</tr>
{else/}
{foreach name="list" item="vo" key="k" }
<tr>
<td class="sort">
<div class="tc w60">
{$vo.aid}
</div>
</td>
<td style="width: 100%;">
<div class="">{$vo.title}</div>
</td>
<td>
<div class="w60 tc">
<input type="hidden" name="aid" id="aid_{$vo.aid}" data-aid="{$vo.aid}" data-title="{$vo.title}" />
<a class="btn blue" href="javascript:void(0);" onClick="select_arc({$vo.aid});"><i class="fa fa-location-arrow"></i>选择</a>
</div>
</td>
</tr>
{/foreach}
{/empty}
</tbody>
</table>
</div>
<div class="iDiv" style="display: none;"></div>
</div>
<div class="tDiv">
<div class="tDiv2">
{include file="public/page" /}
</div>
<div style="clear:both"></div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
// 表格行点击选中切换
$('#flexigrid > table>tbody >tr').click(function(){
$(this).toggleClass('trSelected');
});
// 点击刷新数据
$('.fa-refresh').click(function(){
location.href = location.href;
});
});
// 文档对象
function ArcItem(aid, title) {
this.aid = aid;
this.title = title;
}
function select_arc(aid)
{
var input = $('#aid_'+aid);
var arcItem = null;
arcItem = new ArcItem(input.data('aid'), input.data('title'));
window.parent.sjs_call_back(arcItem);
}
</script>
{include file="public/footer" /}
第三步修改默认的自定义模板application\admin\template\diy_extend\archives_extend.htm
<!-- 用户自定义扩展模板文件,仅用于文档的新增和编辑页面 -->
{php}
// 这里可以实现原生php代码
$diyExtendLogic = new \app\admin\logic\DiyExtendLogic;
{/php}
<!-- 这里自定义HTML表单代码 -->
{if in_array($params.channeltype, [3,10])}
<dl class="row">
<dt class="tit">
<label>学校</label>
</dt>
<dd class="opt">
<span id="sjs_title">{$field.joinaid|getArchivesField=###,'title'}</span>
<input type="hidden" name="joinaid" id="joinaid" value="{$field.joinaid}">
<a href="javascript:void(0);" onclick="diy_select_school(this);" class="ncap-btn ncap-btn-green">学校列表</a>
<span class="err"></span>
<p class="notic"></p>
</dd>
</dl>
<script type="text/javascript">
function diy_select_school(obj)
{
//iframe窗
layer.open({
type: 2,
title: '学校列表',
fixed: true, //不固定
shadeClose: false,
shade: 0.3,
maxmin: true, //开启最大化最小化按钮
area: ['600px', '500px'],
content: "{:url('DiyExtend/select_school')}"
});
}
function sjs_call_back(arcItem)
{
$('#sjs_title').html(arcItem.title);
$('#joinaid').val(arcItem.aid);
layer.closeAll('iframe');
}
</script>
{/if}
效果图如下:
eyoucms文章添加指定关联文章-第1张图片-九零博客 - 一个分享技术、记录生活的个人技术博客
列表调用方法
{eyou:arcview joinaid='$field.joinaid' id='field2'}
<a href="{$field2.arcurl}">{$field2.title}</a>
{/eyou:arcview}
新闻资讯 更多
- 【易优cms教程】eyoucms如何在本地使用授权或插件03-22
- 【易优cms教程】易优cms告侵权怎么办 eyoucms去除底部版权的方法03-22
- 【易优cms教程】eyoucms如何版权?03-22
- 【易优cms教程】易优cms如何去掉版权?eyoucms去除底部版权的思路03-22
- 【易优cms教程】易优cms去除版权方法,如何去除版权,建议购买商业授权03-22
- 【易优cms教程】易优CMS授权开心优缺点是什么?03-22
- 【易优cms教程】易优cms如何去掉版权?eyoucms去除底部版权的思路03-22
- 【易优cms教程】eyoucms 首页以及列表页内容调用标题、关键词、描述02-22
猜你需要
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法