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>";
- //开源软件:Vevb.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>
新闻热点
疑难解答