Home > CMS Tutorial > DEDECMS > body text

How to display different result templates by channel model on the dedecms search results page

藏色散人
Release: 2019-12-16 09:16:30
Original
1332 people have browsed it

How to display different result templates by channel model on the dedecms search results page

dedecms Search results page How to display different result templates by channel model?

dedecms’ own templates include picture models, article models, software models, etc. Sometimes it is necessary to add a judgment to the search box for user experience, such as displaying the template of the software model when searching for software models. , display the template of the article model when searching for article models.

Recommended learning: Dream Weaver cms

The specific implementation code is as follows:

1. Add the

code in the head area as follows :

<script language="javascript" type="text/javascript">
function check(){
if(document.formsearch.channeltype.value=="1")
document.formsearch.action="{dede:field name=&#39;phpurl&#39;/}/search.php"
else
document.formsearch.action="{dede:field name=&#39;phpurl&#39;/}/search_news.php"
}
</script>
Copy after login

2. Change the search code

The code is as follows:

<form name="formsearch" action="" data-ke-onsubmit="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=&#39;keyword&#39; function=&#39;RemoveXSS(@me)&#39;/}" />
<select name="channeltype" id="channeltype" >
<option value=&#39;1&#39; selected=&#39;1&#39;>新闻</option>
<option value=&#39;3&#39;>软件</option>
</select>
<button type="submit" class="search-submit">搜索</button>
</div>
</form>
Copy after login

The key point is

The code is as follows:

<select name="channeltype" id="channeltype" >
<option value=&#39;1&#39; selected=&#39;1&#39;>新闻</option>
<option value=&#39;3&#39;>软件</option>
</select>
Copy after login

Key settings : Search by model set here 1 is the article model 3 is the software model

3. Copy serach.php and rename it to search_images.php

4. Open search_images.php

Change

code as follows:

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

to

code as follows:

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

5. Copy arc.searchview.class.php and rename it to arc.searchimg .class.php

6. Open arc.searchimg.class.php

and find the code for

as follows:

$tempfile = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;]."/".$GLOBALS[&#39;cfg_df_style&#39;]."/search.htm";
Copy after login

is changed to

The code is as follows:

$tempfile = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;]."/".$GLOBALS[&#39;cfg_df_style&#39;]."/search_images.htm
Copy after login

The above is the detailed content of How to display different result templates by channel model on the dedecms search results page. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template