


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='phpurl'/}/search.php" else document.formsearch.action="{dede:field name='phpurl'/}/search_news.php" } </script>
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='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
The code is as follows:
<select name="channeltype" id="channeltype" > <option value='1' selected='1'>新闻</option> <option value='3'>软件</option> </select>
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");
to
code as follows:
require_once(DEDEINC."/arc.searchimg.class.php");
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['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search.htm";
is changed to
The code is as follows:
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search_images.htm
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software