【phpcms-v9】后台发布文章时切换栏目的功能实现
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-23 16:46:08 浏览: 评论:0
1.有时候在后台发布文章时,需要切换栏目.
2.实现第一步,修改modules/content/fields/catid/form.inc.php文件为如下:
- function catid($field, $value, $fieldinfo) {
- if(!$value) $value = $this->catid;
- $publish_str = '';
- if(defined('IN_ADMIN') && ROUTE_A=='add') $publish_str = " <a href='javascript:;' onclick=\"omnipotent('selectid','?m=content&c=content&a=add_othors&siteid=".$this->siteid."','".L('publish_to_othor_category')."',1);return false;\" style='color:#B5BFBB'>[".L('publish_to_othor_category')."]</a><ul class='list-dot-othors' id='add_othors_text'></ul>";
- //开源软件:phpfensi.com
- $publish_str1 = " <a href='javascript:;' onclick=\"omnipotent('selectid','?m=content&c=content&a=change_cat&siteid=".$this->siteid."','".L('change_cat')."',1);return false;\" style='color:#B5BFBB'>[".目标分类."]</a><ul class='list-dot-othors' id='add_othors_text'></ul>";
- return '<input type="hidden" name="info['.$field.']" value="'.$value.'">'.$this->categorys[$value]['catname'].$publish_str.$publish_str1;
- }
3.实现第二步,在modules/content/content.php控制器文件中添加如下函数:
- /**
- * 切换栏目
- */
- public function change_cat() {
- $show_header = '';
- $sitelist = getcache('sitelist','commons');
- $siteid = $_GET['siteid'];
- include $this->admin_tpl('change_cat');
- }
4.实现第三步:在modules/content/templates/下添加change_cat.tpl.php模板文件:
- <?php
- defined('IN_ADMIN') or exit('No permission resources.');
- include $this->admin_tpl('header','admin');
- ?>
- <div class="pad-10">
- <input type="hidden" value="content" name="m">
- <input type="hidden" value="content" name="c">
- <input type="hidden" value="public_relationlist" name="a">
- <input type="hidden" value="<?php echo $modelid;?>" name="modelid">
- <div style="width:500px; padding:2px; border:1px solid #d8d8d8; float:left; margin-top:10px; margin-right:10px; overflow:hidden">
- <table width="100%" cellspacing="0" class="table-list" >
- <thead>
- <tr>
- <th width="100"><?php echo L('catid');?></th>
- <th ><?php echo L('catname');?></th>
- <th width="150" ><?php echo L('select_model_name');?></th>
- </tr>
- </thead>
- <tbody id="load_catgory">
- <?php echo $categorys;?>
- </tbody>
- </table>
- </div>
- <div style="overflow:hidden;_float:left;margin-top:10px;*margin-top:0;_margin-top:0; width:144px">
- <fieldset>
- <legend><?php echo L('category_checked');?></legend>
- <ul class='list-dot-othors' id='catname'></ul>
- </fieldset>
- </div>
- </div>
- <style type="text/css">
- .line_ff9966,.line_ff9966:hover td{background-color:#FF9966}
- .line_fbffe4,.line_fbffe4:hover td {background-color:#fbffe4}
- .list-dot-othors li{float:none; width:auto}
- </style>
- <SCRIPT LANGUAGE="JavaScript">
- <!--
- function select_list(obj,title,id) {
- var relation_ids = window.top.$('#relation').val();
- var sid = 'v'+id;
- $(obj).attr('class','line_fbffe4');
- //var str = "<li id='"+sid+"'>·<input type='hidden' name='othor_catid["+id+"]'><span>"+title+"</span><a href='javascript:;' class='close' onclick=\"remove_id('"+sid+"')\"></a></li>";
- var str = "<li id='"+sid+"'>·<input type='hidden' name='info[catid]' value='"+id+"'><span>"+title+"</span><a href='javascript:;' class='close' onclick=\"remove_id('"+sid+"')\"></a></li>";
- window.top.$('#add_othors_text').emptyempty().append(str);
- $('#catname').emptyempty().append(str);
- if(relation_ids =='' ) {
- window.top.$('#relation').val(id);
- } else {
- relation_ids = relation_ids+'|'+id;
- window.top.$('#relation').val(relation_ids);
- }
- }
- function change_siteid(siteid) {
- $("#load_catgory").load("?m=content&c=content&a=public_getsite_categorys&siteid="+siteid);
- }
- //移除ID
- function remove_id(id) {
- $('#'+id).remove();
- window.top.$('#'+id).remove();
- }
- change_siteid(<?php echo $this->siteid;?>);
- //-->
- </SCRIPT>
- </body>
- </html>
Tags: phpcms后台栏目 phpcms切换栏目
相关文章
- ·【phpcms-v9】解决后台栏目管理只显示顶级栏目名而不显示子(2014-10-23)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)