在搜索模板header中包含了
{pc:content action="lists" catid="14" num="12" order="listorder DESC"} {loop $data $r} <li><a href="{$r['url']}"><span>{$r['title']}</span></a></li> {/loop} {/pc}
搜索结果出现了错误,我们需要修改搜索相关文件
list.html
{loop $data_search $i $v} <li class="product-con-group-inner"> <a href="{$v['url']}" title="{$v['title']}"> <div class="product-img"><span>{if $v[thumb]}<img src="{$v[thumb]}" alt="{$v[title]}">{else}<img src="{siteurl($siteid)}/images/layout/no_img.jpg" alt="{$v[title]}" />{/if}</span></div> <div class="product-name"> <h5>{$v[title]}</h5> <p></p> </div> </a> </li> {/loop} {if empty($data_search)}未找到结果{/if}
phpcms/modules/search/index.php 修改下面内容,注意原先的data全部修改为data1
//是否读取其他模块接口 if($modelid) { $this->content_db->set_model($modelid); /** * 如果表名为空,则为黄页模型 */ if(empty($this->content_db->model_tablename)) { $this->content_db = pc_base::load_model('yp_content_model'); $this->content_db->set_model($modelid); } if($setting['sphinxenable']) { $data_search = $this->content_db->listinfo($where, 'id DESC', 1, $pagesize); $pages = pages($totalnums, $page, $pagesize); } else { $data_search = $this->content_db->select($where, '*'); $pages = $this->db->pages; $totalnums = $this->db->number; } //如果分词结果为空 if(!empty($segment_q)) { $replace = explode(' ', $segment_q); foreach($replace as $replace_arr_v) { $replace_arr[] = ''.$replace_arr_v.''; } foreach($data_search as $_k=>$_v) { $data_search[$_k]['title'] = str_replace($replace, $replace_arr, $_v['title']); $data_search[$_k]['description'] = str_replace($replace, $replace_arr, $_v['description']); } } else { foreach($data as $_k=>$_v) { $data_search[$_k]['title'] = str_replace($q, ''.$q.'', $_v['title']); $data_search[$_k]['description'] = str_replace($q, ''.$q.'', $_v['description']); } } } else { //读取专辑搜索接口 $special_api = pc_base::load_app_class('search_api', 'special'); $data_search = $special_api->get_search_data($sids); $totalnums = count($data_search); } } $execute_time = execute_time(); $pages = isset($pages) ? $pages : ''; $totalnums = isset($totalnums) ? $totalnums : 0; $data_search = isset($data_search) ? $data_search : ''; include template('search','list'); } else { include template('search','index'); }
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
相关文章
phpcms-v9中将一个站点下的文章内容完美的推送到另一个站点下2024-09-24
phpcms loop循环判断是否为最后一条的代码2024-06-18
Phpcms V9 文章或图片模型增加相关下载功能2022-12-30
phpcms文章列表增加一键推送到百度功能2022-12-08
phpcms 标题SEO栏目不同的代码2022-11-14
PHPCMS替换内容的两种方法:str_replace和preg_replace2022-10-25
phpcms 搜索结果第一页比设定的多一条数据的解决办法2021-01-05
phpcms v9 字段多行文本不换行的解决办法2020-09-22
phpcms 栏目和文章页面“您没有访问该信息的权限”跳转登陆页面2020-09-17
phpcms转向链接过滤#的问题解决2020-04-23