织梦怎么实现搜索结果不同模型不同模板

92建站   织梦CMS   2021-04-11   收藏本文

本文介绍了织梦怎么实现搜索结果不同模型不同模板,解决思路:首先在HEAD区域加入教程给出的代码,然后更改搜索代码为新的,最后在search_images.php里面添加教程给出的新的代码就可以了。

旺铺招租1 旺铺招租2 旺铺招租3

织梦怎么实现搜索结果不同模型不同模板?你知道如何实现dede搜索结果页面根据频道模型显示不同的模板吗?许多朋友在网上看到这个问题,并问如何实现它。一起来看看吧。

具体实现代码:

1 在head区域加入

<script language="javascript" type="text/javascript">

<!--

function check(){

if(document.formsearch.channeltype.value=="3")

document.formsearch.action="{dede:field name='phpurl'/}/search_images.php"

else

document.formsearch.action="{dede:field name='phpurl'/}/search.php"

}

-->

</script>

2  更改搜索代码

<form  name="formsearch" action="" *****ubmit="check();">

<div class="form">

<input type="hidden" name="kwtype" value="0" />

<input name="q" type="text" class="search-keyword" id="search-keyword" value="{dede:global name='keyword' function='RemoveXSS(@me)'/}" />

<select name="channeltype" id="channeltype" >

<option value='1' selected='1'>新闻</option>

<option value='3'>软件</option>

</select>

<button type="submit" class="search-submit">搜索</button>

</div>

</form>

其中重点就是

<select name="channeltype" id="channeltype" >

<option value='1' selected='1'>新闻</option>

<option value='3'>软件</option>

</select>

关键设置:这里设置的按游戏模型搜索  1是文章模型 3是软件模型

3 复制serach.php 更名为 search_images.php

4 打开 search_images.php 

require_once(DEDEINC."/arc.searchview.class.php");

更改为

require_once(DEDEINC."/arc.searchimg.class.php");

5复制 arc.searchview.class.php 更名为 arc.searchimg.class.php

6 打开 arc.searchimg.class.php

修改

$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search.htm";

$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search_images.htm";

核心的修改已经结束了,剩下的就是在search_images.htm这个模板里自由发挥了。

同理也可以实现按栏目type搜索显示不同风格的结果页得。

上面就是织梦实现不同模板的介绍,若有疑问可以找小编进一步探讨交流~

旺铺招租4
旺铺招租5
展开