国产激情高潮在线观看-中文字幕有码视频推荐-国产三级全黄芒果视频-久久国产美女一区精品

18038435860

JTBC_PHP版本實(shí)現(xiàn)全站搜索功能

時(shí)間:2018-10-26 11:55:35 點(diǎn)擊:1290 來源:易速網(wǎng)絡(luò)

1、打開search/common/incfiles/module_config.inc.php
覆蓋原來的function jtbc_cms_module_list() 也就是7到71行代碼。
function jtbc_cms_module_list()
{
    global $variable;
  global $ngenre, $npagesize, $nlisttopx;
  global $nsearch_genre, $nsearch_field;
    $tshkeyword = ii_get_safecode($_GET['keyword']);
  $toffset = ii_get_num($_GET['offset']);
  if (ii_isnull($tshkeyword)) mm_imessage(ii_itake('module.keyword_error', 'lng'), -1);
  $tshkeywords = explode(' ', $tshkeyword);
  if (count($tshkeywords) > 5) mm_imessage(ii_itake('module.complex_error', 'lng'), -1);
    $font_red = ii_itake('global.tpl_config.font_red', 'tpl');
  $tmpstr = ii_itake('module.list', 'tpl');
  $tmpastr = ii_ctemplate($tmpstr, '{@recurrence_ida}');
    $tmprstr = '';
        $tndatabases = explode(',', $nsearch_genre);
        $tnfields = explode(',', $nsearch_field);
        $tsqlstr = "";
        for ($ti = 0; $ti < count($tndatabases); $ti ++)
        {
            $tndatabase = $tndatabases[$ti];
            $turltype = ii_get_num($variable[ii_cvgenre($tndatabase) . '.nurltype']);
            $tcreatefolder = $variable[ii_cvgenre($tndatabase) . '.ncreatefolder'];
            $tcreatefiletype = $variable[ii_cvgenre($tndatabase) . '.ncreatefiletype'];
            $tdatabase = $variable[ii_cvgenre($tndatabase) . '.ndatabase'];
            $tidfield = $variable[ii_cvgenre($tndatabase) . '.nidfield'];
            $tfpre = $variable[ii_cvgenre($tndatabase) . '.nfpre'];
            $tunion = " union all ";
            $tsqlstr .= "select * from (";
            $tsqlstr .= "select " . $tidfield . " as un_id,";
            foreach ($tnfields as $tnfield)
            {
                $tsqlstr .= ii_cfnames($tfpre, $tnfield) . " as un_" . $tnfield . ",";
            }
            $tsqlstr .= ii_cfnames($tfpre, 'count') . " as un_count," . ii_cfnames($tfpre, 'time') . " as un_time,'" . $tndatabase . "' as un_genre from " . $tdatabase . " where " . ii_cfnames($tfpre, 'hidden') . "=0";
            foreach ($tshkeywords as $key => $val)
            {
                foreach ($tnfields as $tnfield)
                {
                    if($tnfield == 'topic') $tsqlstr .= " and " . ii_cfnames($tfpre, $tnfield) . " like '%" . $val . "%'";
                    else $tsqlstr .= " or " . ii_cfnames($tfpre, $tnfield) . " like '%" . $val . "%'";
                }
            }
            if($ti == count($tndatabases) - 1) $tsqlstr .= " order by " . ii_cfnames($tfpre, 'time') . " desc) as un_" . $tndatabase;
            else $tsqlstr .= " order by " . ii_cfnames($tfpre, 'time') . " desc) as un_" . $tndatabase . $tunion;
        }
        $tcp = new cc_cutepage;
        $tcp -> id = 'un_id';
        $tcp -> pagesize = $npagesize;
        $tcp -> rslimit = $nlisttopx;
        $tcp -> sqlstr = $tsqlstr;
        $tcp -> offset = $toffset;
        $tcp -> init(); 
        $trsary = $tcp -> get_rs_array();
        if (is_array($trsary))
        {
            foreach($trsary as $trs)
            {
                $tfshkeyword = '';
                $tmptstr = $tmpastr;
                $tfshkeyword = str_replace('{$explain}', $tshkeyword, $font_red);
                $ttopic = ii_htmlencode($trs['un_topic']);
                $tcontent = $trs['un_content'];
                $tmptstr = str_replace('{$topicstr}', $ttopic, $tmpastr);
                if (!ii_isnull($tfshkeyword))
                {
                    $ttopic = str_replace($tshkeyword, $tfshkeyword, $ttopic);
                    $tcontent = str_replace($tshkeyword, $tfshkeyword, $tcontent);
                }
                $tmptstr = str_replace('{$topic}', $ttopic, $tmptstr);
                $tmptstr = str_replace('{$content}', $tcontent, $tmptstr);
                $tmptstr = str_replace('{$time}', ii_get_date($trs['un_time']), $tmptstr);
                $tmptstr = str_replace('{$count}', ii_get_num($trs['un_count']), $tmptstr);
                $tmptstr = str_replace('{$id}', ii_get_num($trs['un_id']), $tmptstr);
                $tmptstr = str_replace('{$baseurl}', ii_get_actual_route($trs['un_genre']) . '/', $tmptstr);
                $tmprstr .= $tmptstr;
            }
        }
        $tmpstr = str_replace(JTBC_CINFO, $tmprstr, $tmpstr);
        $tmpstr = str_replace('{$urltype}', $turltype, $tmpstr);
        $tmpstr = str_replace('{$createfolder}', $tcreatefolder, $tmpstr);
        $tmpstr = str_replace('{$createfiletype}', $tcreatefiletype, $tmpstr);
        $tmpstr = str_replace('{$cpagestr}', $tcp -> get_pagestr(), $tmpstr);
        $tmpstr = str_replace('{$genre}', $ngenre, $tmpstr);
        $tmpstr = ii_creplace($tmpstr);
        return $tmpstr;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2、模版管理-編輯代號(hào)search.tpl.module 提交,替換掉之前l(fā)ist節(jié)點(diǎn)的模版
{$=mm_web_head($GLOBALS['nhead'])}
<div id="middle">
  <div id="middleContent">
    <div class="middleSide">
      <div class="box1">
        <h3>{$=ii_itake('global.lng_config.search','lng')}</h3>
        <div class="box1s">
          <form method="get" name="search">
          <table width="100%" cellpadding="0" cellspacing="0" border="0">
            <tr>
              <td height="25"><input type="text" name="keyword" size="15" value="{$=ii_htmlencode($_GET['keyword'])}" class="text" /></td>
            </tr>
            <tr>
              <td height="25"><input type="submit" value="{$=ii_itake('global.lng_config.search','lng')}" class="button" /></td>
            </tr>
          </table>
          </form>
        </div>
      </div>
    </div>
    <div class="middleMain">
      <div class="middleMainContent">
        <table cellpadding="0" cellspacing="0" class="tablen">
          <tr>
            <td class="nav"><span>{$=vv_inavigation('{$genre}', 'strers=module')}</span></td>
          </tr>
          <tr>
            <td class="list" valign="top">
              <table width="100%" cellpadding="0" cellspacing="0" border="0">{@recurrence_ida}
                <tr>
                  <td class="tit1"><img src="{$=#global_images_route}public/small/sico.gif" alt="ICO" /> <a href="{$=ii_curl('{$baseurl}', ii_iurl('detail', {$id}, {$urltype}, 'folder={$createfolder};filetype={$createfiletype};time={$time}'))}" title="{$topicstr}">{$topic}</a></td>
                  <td>{$content}</td>
                                    <td width="130" class="time1"><span>{$time}</span></td>
                                </tr>{@recurrence_ida}
              </table>
            </td>
          </tr>
          <tr>
            <td height="10"></td>
          </tr>
          <tr>
            <td><div id="cutepage" class="cutepage">{$cpagestr}</div></td>
          </tr>
          <tr>
            <td height="10"></td>
          </tr>
        </table>
      </div>
    </div>
    <div class="clear"></div>
  </div>
</div>
{$=mm_web_foot($GLOBALS['nfoot'])}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~·
3、前臺(tái)模版調(diào)用代碼
<form method="get" name="search" action="search">
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td width="10" height="10"></td>
            <td></td>
          </tr>
          <tr>
            <td></td>
            <td height="25"><strong>{$=ii_itake('global.lng_config.search', 'lng')}</strong></td>
          </tr>
          <tr>
            <td></td>
            <td height="35">{$=ii_itake('global.lng_config.keyword', 'lng')} <input type="text" name="keyword" size="15" class="text" /> <input type="submit" value="{$=ii_itake('global.lng_config.search','lng')}" class="button" /></td>
          </tr>
          <tr>
            <td height="10"></td>
            <td></td>
          </tr>
        </table>
        </form>

4、找到根目錄/common/incfiles/class.inc.php文件,修改分頁類
  function get_rs_count()
  {
    global $conn;
  //$tsqlstr = 'select count(' . $this -> id . ') from' . ii_get_lrstr($this -> sqlstr, 'from', 'rightr');
    $tsqlstr = $this -> sqlstr;
    $trs = ii_conn_query($tsqlstr, $conn);
    $trs = ii_conn_fetch_array($trs);
    return $trs[0]+1;
  }

影子說明:因修改后的搜索是聯(lián)表查詢,分頁類是針對(duì)一個(gè)表查詢,所以需要修改。
影子建議,把分頁類復(fù)制一份修復(fù),以免對(duì)其它處產(chǎn)生影響,請(qǐng)謹(jǐn)慎使用,責(zé)任自負(fù)。


5、配置管理→(站內(nèi)搜索)search,設(shè)置 可被搜索的模塊名,把需要搜索的模塊名加上,把已經(jīng)不存在的模塊名刪掉。然后刪除緩存。(完)

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~·

補(bǔ)充:

分頁出錯(cuò),是因?yàn)樯倭艘恍写a,加上即可。

$tcp = new cc_cutepage;
        $tcp -> id = 'un_id';
        $tcp -> pagesize = $npagesize;
        $tcp -> rslimit = $nlisttopx;
        $tcp -> sqlstr = $tsqlstr;
        $tcp -> offset = $toffset;
        $tcp -> init(); 
        $trsary = $tcp -> get_rs_array();
        if (is_array($trsary))
添加一行,紅色的部分

//2017.03.16添加修正內(nèi)容
上面一行繼續(xù)添加

再修改分頁類
  function get_rs_count()
  {
    global $conn;
  //$tsqlstr = 'select count(' . $this -> id . ') from' . ii_get_lrstr($this -> sqlstr, 'from', 'rightr');
    $tsqlstr = $this -> sqlstr;
    $trs = ii_conn_query($tsqlstr, $conn);
    $trs = ii_conn_fetch_array($trs);
    return $trs[0]+1;
  }

說明:因修改后的搜索是聯(lián)表查詢,分頁類是針對(duì)一個(gè)表查詢,所以需要修改。

個(gè)人建議,把分頁類復(fù)制一份修復(fù),以免對(duì)其它處產(chǎn)生影響,請(qǐng)謹(jǐn)慎使用,責(zé)任自負(fù)。

//2018年7月11日更新 修復(fù)多模塊查詢結(jié)果為空的bug
$tsqlstr = 'select count(' . $this -> id . ') from (' . $this -> sqlstr .') as sum';
    $trs = ii_conn_query($tsqlstr, $conn);
    $trs = ii_conn_fetch_array($trs);
    return $trs[0];

奇台县| 陆良县| 古浪县| 麟游县| 扶余县| 德令哈市| 马尔康县| 寿宁县| 广饶县| 芜湖市| 西充县| 深泽县| 定西市| 金秀| 靖宇县| 霸州市| 二连浩特市| 莱州市| 五寨县| 麻阳| 当涂县| 三江| 磴口县| 济宁市| 台北县| 和静县| 新余市| 屏山县| 榆社县| 鄂伦春自治旗| 中西区| 静乐县| 博野县| 龙胜| 简阳市| 开原市| 天水市| 哈密市| 通渭县| 友谊县| 营山县|