Home> CMS Tutorial> DEDECMS> body text

How to call custom fields in DreamWeaver search results

藏色散人
Release: 2020-01-06 09:25:14
Original
1702 people have browsed it

How to call custom fields in DreamWeaver search results

How to call custom fields in Dreamweaver search results?

Dreamweaver DEDECMS search results call custom fields

Recommended learning:Dreamweavercms

Call custom fields on the search page, Is it possible to allow users to search for this custom field? After searching many articles and tutorials, I found that the underlying template field of the dedecms label does not include this field? This greatly limits the flexibility, but it is also impossible to allow all fields to be called, which will greatly reduce the system efficiency. So what I share today is a relatively perfect method to solve this problem. With the dede tag, it can be said that there is almost no such thing. What cannot be called?

First put the above code into include/extend.func.php

Usage:

function table($table, $field, $id) { global $dsql; $primarys = array(); $table = strpos($table, '#@_') === false?(strpos($table, 'dede_') === false?'cn_'.$table:str_replace('dede_','cn_',$table)):$table; $dsql -> Execute("me","SHOW COLUMNS FROM `$table`"); while ($r = $dsql->GetArray()) { if($r['Key'] == 'PRI') $primarys[] = $r['Field']; } if(!emptyempty($primarys)) { $primary = $primarys[0]; $result = $dsql -> GetOne("SELECT `$field` FROM `$table` WHERE `$primary`= $id"); } return isset($result[$field])?$result[$field]:''; }
Copy after login

The above is the detailed content of How to call custom fields in DreamWeaver search results. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!