搜索结果调用其他字段的办法

2020-03-11 3100 次

一直有人要搜索结果调用其他字段的信息 比如图片等等 一直忙没顾上 官方其实已经内置了一个内容读取器。


我们打开搜索的结果模板template\index_style\你的模板目录\search\index\ pc_lists.htm

我们在 {volist name="lists" id="rs"} 里面加代码就可以实现 比如我们在 {$rs.des} 下面加上


文雅点的加法:

{php}$show=fun('Content@info',$rs['id'],$rs['module']);{/php}

图片:{$show['picurl']} 关键词:{$show['keywords']}..... 你就会发现 {$show['我们的字段名']}

暴力型的加法:

{:fun('Content@info',$rs['id'],$rs['module'])['keywords']}  {:fun('Content@info',$rs['id'],$rs['module'])['picurl']} 

推荐文雅的办法

大概就是这样调用的

<div id="hd_main" style="min-width: 1100px;">
  <div id="res" class="res">
    <div id="result"> {volist name="lists" id="rs"}
      <div class="g">
        <h2><a href="{:url($rs.module.'/content/show',['id'=>$rs['id']],'html',true)}" target="_blank" class="s">{$rs.title}</a></h2>
        <div class="std">{$rs.des}
{php}$show=fun('Content@info',$rs['id'],$rs['module']);{/php}
图片地址:{$show['picurl']} 关键词:{$show['keywords']} 
			
	 
		  </div>
        <span class="a">{:url($rs.module.'/content/show',['id'=>$rs['id']],'html',true)}</span> <span class="a">{$rs.create_time}</span></div>
      {/volist} </div>
    <div class="cl"></div>
    <div id="sopage"> {$data->render()} </div>
  </div>
  <div id="sidebar">
    <div class="rankbox">
      <div class="title">今日实时热搜</div>
      <ul class="ranklist">
        {volist name="resou" id="rs" key="k"}
        <li><span class="num {lt name="k" value="4"}top1{/lt}">{$k}</span><a href="{:url('search/index/lists','html',true)}?keyword={$rs.keyword}">{$rs.keyword}</a></li>
        {/volist}
      </ul>
    </div>
  </div>
</div>



标签
声明:
1.本站的资源收集于互联网,仅供大家学习交流,请勿用于非法用途,否则后果自负!
2.如转载本站的原创文章,请勿必注明文章来源,对于不尊重原创的行为我们将追究责任