發(fā)布日期: 2023-07-10 | 來源: 智軟設(shè)計工作室
最近制作網(wǎng)站的時候。因為搜索的地方比較多。比如常見問題和經(jīng)銷商,產(chǎn)品,都得搜索,用傳統(tǒng)得{pboot:scaction} 他都會到統(tǒng)一得頁面去,當然頁可以用 <input type="hidden" name="searchtpl" value="1.html" >,置頂不同模板,但是置頂后。有些問題。比如欄目封面和當前位置,都會到搜索哪里。當然你頁可以定死,但是不太靈活,萬一后面又有其他欄目就又要做個模板了。下面是pboot:list列表頁直接搜索得解決方法:
先找到:apps/home/controller/ParserController.php
找到:
然后:
$count = count($matches[0]);
下面添加:
/*添加列表直接搜索 */
$keyword = request('keyword', 'vars');
/*end */然后在
下面添加:
// 采取keyword方式
if ($keyword) {
if (strpos($field, '|')) { // 匹配多字段的關(guān)鍵字搜索
$field = explode('|', $field);
foreach ($field as $value) {
if ($value == 'title') {
$value = 'a.title';
}
if ($fuzzy) {
$like = " like '%" . $keyword . "%'"; // 前面已經(jīng)轉(zhuǎn)義過
} else {
$like = " like '" . $keyword . "'"; // 前面已經(jīng)轉(zhuǎn)義過
}
if (isset($where3[0])) {
$where3[0] .= ' OR ' . $value . $like;
} else {
$where3[0] = $value . $like;
}
}
if (count($field) > 1) {
$where3[0] = '(' . $where3[0] . ')';
}
} else { // 匹配單一字段的關(guān)鍵字搜索
if ($field) {
if ($field == 'title') {
$field = 'a.title';
}
$where3[$field] = $keyword;
} else {
$where3['a.title'] = $keyword;
}
}
}
// 數(shù)據(jù)接收
if ($_POST) {
$receive = $_POST;
} else {
$receive = $_GET;
}
foreach ($receive as $key => $value) {
if (! ! $value = request($key, 'vars')) {
if ($key == 'title') {
$key = 'a.title';
}
if (preg_match('/^[w-.]+$/', $key)) { // 帶有違規(guī)字符時不帶入查詢
$where3[$key] = $value;
}
}
}
// 去除特殊鍵值
unset($where3['keyword']);
unset($where3['field']);
unset($where3['scode']);
unset($where3['page']);
unset($where3['from']);
unset($where3['isappinstalled']);
unset($where3['tdsourcetag']);
unset($where3['x']);
unset($where3['y']);
unset($where3['searchtpl']);
unset($where3['p']);
unset($where3['s']);
// 無任何條件不顯示內(nèi)容
/* 取消。不然進入沒條件,列表頁不顯示內(nèi)容,
if (! $where3) {
$content = str_replace($matches[0][$i], '', $content);
continue;
}
/*
end
*/然后還要找到:IndexController.php
在44行左右:
//加入列表頁直接搜索?keyword條件,不然會出現(xiàn)您訪問的內(nèi)容不存在,請核對后重試
if(stripos(URL,'?') !== false && stripos(URL,'/?tag=') == false && stripos(URL,'/?page=') == false && stripos(URL,'/?ext_') == false && stripos(URL,'/?keyword') == false){
_404('您訪問的內(nèi)容不存在,請核對后重試!');
}ParserController文件在里面,pbootcms3.2.5
加入list標簽直接keyword搜索,ParserController.rar
2024-04-28
大概 代碼。是這樣的。{pboot:nav num=10 parent=0}{pboot:if([nav:soncount]>0)}menu-item-has-children{/pboot:if} {pboot:2nav parent=[nav:scode]} {pboot:if([2nav:soncount]>0)}menu-item-has-children{/pboot:if} {pboot:3
閱讀更多2024-03-22
if($matches1[0]){if($_SERVER['REQUEST_URI']==$matches1[0]){$this->getIndexPage();&nbs
閱讀更多2023-07-03
今天遇到一個網(wǎng)站有三級欄目,要求是。點擊二級顯示三級子類。點擊三級顯示同級別分類,以下代碼可以實現(xiàn),通過判斷是否有子類。來判斷顯示什么級別內(nèi)容,parent=可以自己按需求來。是下級還是同級還是頂級。{sort:scode}{sort:tcode}{sort:pcode}{pboot:if('{pboot:navpa
閱讀更多2024-09-29
pboot:nav 判斷沒有子類得時候顯示同級欄目 ,如果有子類 就 顯示子類。{pboot:if('{pboot:nav parent={sort:scode}}[nav:name]{/pboot:nav}'!='')} {pboot:nav parent={sort:scode}} <li><a class="{pboot:2if('[nav:scode]'=='{sort:scode}
閱讀更多2022-12-06
PBOOTCMS重置欄目ID和文章id從1開始自增,SQLITE數(shù)據(jù)庫重置id從1開始DELETE FROM SQLITE_SEQUENCE WHERE NAME = 'ay_content'sqlite_sequence表也是SQLite的系統(tǒng)表改后面的表名稱就行了。
閱讀更多2021-11-11
激活步驟:1.如下圖,以管理員運行;2.輸入:123slmgr /ipk WC2BQ-8NRM3-FDDYY-2BFGV-KHKQYslmgr /skms kms.03k.orgslmgr /ato
閱讀更多2023-06-27
今天做網(wǎng)站,一個客戶應(yīng)為美觀要求。一次性刪除內(nèi)容里面的--符號,由于現(xiàn)在數(shù)據(jù)量比較大了,所有采取jq的方式,$("div").html(function(i,html){returnhtml.replace(/--/g,"");});這段代碼使用了正則表達式 /--/g 來匹配并替換所有連字符 "--"。它會遍
閱讀更多2023-05-09
css字體漸變顏色background-image:-webkit-linear-gradient(bottom,#fb1919,#fd8403,#75751e);-webkit-background-clip:text;-webkit-text-fill-color:transparent;這里要注意。如果設(shè)置了這個。css字體移動樣式也要設(shè)置。不然普通字體移動變色。沒有效果,css背景漸變顏色代碼如下:background-image: linear-gradient(140d
閱讀更多2023-04-06
效果如下,div代碼如下:<div class="h_1"><span>002t.cn<br>DESIGN&<br><b>網(wǎng)站建設(shè)</b></span></div>css代碼如下:.h_1{ position: absolute; background
閱讀更多