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、模版管理-编辑代号search.tpl.module 提交,替换掉之前list节点的模版
{$=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、前台模版调用代码
<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;
}

影子说明:因修改后的搜索是联表查询,分页类是针对一个表查询,所以需要修改。
影子建议,把分页类复制一份修复,以免对其它处产生影响,请谨慎使用,责任自负。

此教程红色部分感谢影子技术支持。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~·
5、配置管理→(站内搜索)search,设置 可被搜索的模块名,把需要搜索的模块名加上,把已经不存在的模块名删掉。然后删除缓存。

原文地址:https://www.jtbc.cn/forum/detail-18750.html

发表评论

共有 0 条评论