phpcmsv9关联链接 搜索功能

时间:2016-04-19416举报小编:jong

    关联链接如果不多的话还好,多了之后要找一个词就会很麻烦!这个功能有效的解决了这个麻烦事!

    先上个截图

    phpcmsv9关联链接 搜索功能

    话不多说直接开始!!

    先打开\phpcms\modules\admin\keylink.php

    在94行也就是 关联词删除 结束后 加上

            /**
             * 关联词搜索
             * Jong 2016-4-15 6:02
             */
            public function search_keylink() {
             $where = '';
             if($_GET['search']) extract($_GET['search']);
             if($word){
    $where .= $where ?  " AND word LIKE '%$word%'" : " word LIKE '%$word%'";
     }
    
    $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
    $infos = $this->db->listinfo($where,$order = 'word DESC',$page, $pages = '50');
    $pages = $this->db->pages;
    $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=admin&c=keylink&a=add\', title:\''.L('add_keylink').'\', width:\'450\', height:\'130\'}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('add_keylink'));
    include $this->admin_tpl('keylink_search_list');
        }

    在\phpcms\modules\admin\templates\keylink_list.tpl.php搜索

    也就是第6行下面加上

    <form name="searchform" action="?m=admin&c=keylink&a=search_keylink&menuid=<?php echo $_GET['menuid'];?>" method="get" >
    <input type="hidden" value="admin" name="m">
    <input type="hidden" value="keylink" name="c">
    <input type="hidden" value="search_keylink" name="a">
    <table width="100%" cellspacing="0" class="search-form">
        <tbody>
                    <tr>
                    <td><div class="explain-col">关键词:  <input type="text" value="" class="input-text" name="search[word]">    <input type="submit" value="<?php echo L('search')?>" class="button" name="dosubmit">
                    </div>
                    </td>
                    </tr>
        </tbody>
    </table>
    </form>

    在\phpcms\modules\admin\templates\   添加 keylink_search_list.tpl.php

    <?php
    defined('IN_ADMIN') or exit('No permission resources.');
    $show_dialog = 1;
    include $this->admin_tpl('header','admin');
    ?>
    <div class="pad-lr-10">
    <form name="searchform" action="?m=admin&c=keylink&a=search_keylink&menuid=<?php echo $_GET['menuid'];?>" method="get" >
    <input type="hidden" value="admin" name="m">
    <input type="hidden" value="keylink" name="c">
    <input type="hidden" value="search_keylink" name="a">
    <table width="100%" cellspacing="0" class="search-form">
        <tbody>
                    <tr>
                    <td><div class="explain-col">关键词:  <input type="text" value="" class="input-text" name="search[word]">    <input type="submit" value="<?php echo L('search')?>" class="button" name="dosubmit">
                    </div>
                    </td>
                    </tr>
        </tbody>
    </table>
    </form>
    <form name="myform" id="myform" action="?m=admin&c=keylink&a=delete" method="post" onsubmit="checkuid();return false;">
    <div class="table-list">
    <table width="100%" cellspacing="0">
            <thead>
                <tr>
                <th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('keylinkid[]');"></th>
                 <th width="30%"><?php echo L('keyword_name')?></th>
                <th ><?php echo L('link_url')?></th> 
                 <th width="120"><?php echo L('operations_manage')?></th>
                </tr>
            </thead>
        <tbody>
    <?php
    if(is_array($infos)){
            foreach($infos as $info){
    ?>
        <tr>
        <td align="center">
            <input type="checkbox" name="keylinkid[]" value="<?php echo $info['keylinkid']?>">
            </td> 
            <td width="30%" align="left"><span  class="<?php echo $info['style']?>"><?php echo $info['word']?></span> </td>
            <td align="center"><?php echo $info['url']?></td>
             <td align="center"><a href="javascript:edit(<?php echo $info['keylinkid']?>, '<?php echo new_addslashes($info['word'])?>')"><?php echo L('edit')?></a> | <a href="javascript:confirmurl('?m=admin&c=keylink&a=delete&keylinkid=<?php echo $info['keylinkid']?>', '<?php echo L('keylink_confirm_del')?>')"><?php echo L('delete')?></a> </td>
        </tr>
    <?php
            }
    }
    ?></tbody>
    </table>
    <div class="btn">
    <a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('selected_all')?></a>/<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a>
    <input type="submit" name="submit" class="button" value="<?php echo L('remove_all_selected')?>"  onClick="return confirm('<?php echo L('badword_confom_del')?>')" /> 
    </div> 
    <div id="pages"><?php echo $pages?></div>
    </div>
    </form>
    </div>
    </body>
    </html>
    <script type="text/javascript">
    function edit(id, name) {
            window.top.art.dialog({id:'edit'}).close();
            window.top.art.dialog({title:'<?php echo L('keylink_edit')?> '+name+' ',id:'edit',iframe:'?m=admin&c=keylink&a=edit&keylinkid='+id,width:'450',height:'130'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
    }
    
    function checkuid() {
            var ids='';
            $("input[name='keylinkid[]']:checked").each(function(i, n){
                    ids += $(n).val() + ',';
            });
            if(ids=='') {
                    window.top.art.dialog({content:'<?php echo L('badword_pleasechose')?>',lock:true,width:'200',height:'50',time:1.5},function(){});
                    return false;
            } else {
                    myform.submit();
            }
    }
    </script>

    至此大工告成!更多PHPCMS技术文章敬请关注未来软件园.