Home >CMS Tutorial >DEDECMS >How to display different templates according to channel model on the Dreamweaver search results page
How to display different templates according to channel models on the Dreamweaver search results page?
The DEDECMS search results page displays different templates according to channel models
Recommended learning: DDEECMS
Ideas: Give the search box Add a judgment, for example, a template will be displayed when searching for software models, and a template will be displayed when searching for article models.
1. Add
<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>
in the head area 2. Change the search code
<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>
The key point is
<select name="channeltype" id="channeltype" > <option value='1' selected='1'>新闻</option> <option value='3'>软件</option> </select>
Search by game model set here 1 is Article model 3 is a software model
3. Copy serach.php and rename it to search_images.php
4. Open search_images.php
require_once(DEDEINC."/arc.searchview.class.php");
and change it to
require_once(DEDEINC."/arc.searchimg.class.php");
5. Copy arc.searchview.class.php and rename it arc.searchimg.class.php
6. Open arc.searchimg.class.php
Modify
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search.htm";
The core modifications for
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search_images.htm";
have been completed, and all that is left is to play freely in the search_images.htm template. In the same way, you can also search by column type and display different styles of result pages.
The above is the detailed content of How to display different templates according to channel model on the Dreamweaver search results page. For more information, please follow other related articles on the PHP Chinese website!