Get the App
SLTechnology News&Howtos  ›  Servers  › 

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

Shulou Source: shulou.com Published: 2022-06-02 03:35:18 10月02日 Update

Editor to share with you how the dedecms search results page can display different result templates according to the channel model. I hope you will gain a lot after reading this article. Let's discuss it together.

How can the dedecms search results page display different result templates by channel model?

Dedecms has its own templates, such as picture model, article model, software model and so on. Sometimes it is necessary to add a decision to the search box for the sake of user experience, such as the template that displays the software model when searching for the software model and the template that displays the article model when searching for the article model.

The specific implementation code is as follows:

1. Join in the head area

The code is as follows:

Function check () {if (document.formsearch.channeltype.value== "1") document.formsearch.action= "{dede:field name='phpurl'/} / search.php" elsedocument.formsearch.action= "{dede:field name='phpurl'/} / search_news.php"}

two。 Change the search code

The code is as follows:

News software search

The point is that

The code is as follows:

News software

Key settings: search by model 1 is the article model 3 is the software model

3. Copy serach.php and change its name to search_images.php

4. Open search_images.php

Set

The code is as follows:

Require_once (DEDEINC. "/ arc.searchview.class.php"

Change to

The code is as follows:

Require_once (DEDEINC. "/ arc.searchimg.class.php"

5. Copy arc.searchview.class.php and change its name to arc.searchimg.class.php

6. Open arc.searchimg.class.php

Find

The code is as follows:

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

Change to

The code is as follows:

$tempfile = $GLOBALS ['cfg_basedir']. $GLOBALS [' cfg_templets_dir']. "/". $GLOBALS ['cfg_df_style']. "/ search_images.htm has finished reading this article. I believe you have some understanding of how the dedecms search results page can display different result templates according to the channel model. If you want to know more about it, welcome to follow the industry information channel. Thank you for reading!

Tags: Models searches code templates results software channels articles differences search results news times articles keys areas finished that is more there are pictures sometimes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS Microsoft MariaDB Shulou Technology