版本:DouPHP_1.5_Release_20181105
错误:DouPHP官方模板手机版产品搜索结果页无法显示缩略图
(截图来自douphp官网)
除了这个手机版的搜索结果页,其他位置的缩略图都是正常的,排除了数据库或添加产品时可能造成的原因。
后来发现,是生成网页文件时造成的。这是 search.inc.php Bug 造成的,修改 search.inc.php 即可恢复正常。
文件位于:/m/include/search.inc.php
解决方法:打开 search.inc.php 文件,用以下代码完全覆盖并保存即可。
<?php /** * DouPHP * -------------------------------------------------------------------------------------------------- * 版权所有 2013-2018 漳州豆壳网络科技有限公司,并保留所有权利。 * 网站地址: http://www.douco.com * -------------------------------------------------------------------------------------------------- * 这不是一个自由软件!您只能在遵守授权协议前提下对程序代码进行修改和使用;不允许对程序代码以任何形式任何目的的再发布。 * 授权协议:http://www.douco.com/license.html * -------------------------------------------------------------------------------------------------- * Author: DouCo * Release Date: 2018-11-17 by bg7iae */ if (!defined('IN_DOUCO')) { die('Hacking attempt'); } // 初始化 $module = $check->is_letter($_REQUEST['module']) ? $_REQUEST['module'] : 'product'; switch ($module) { case 'product' : // 产品模块 $name_field = 'name'; $smarty->assign('keyword', $keyword); $search_url = M_PATH . '?s='; break; default : $name_field = 'title'; $smarty->assign('keyword_article', $keyword); $search_url = M_PATH . '?module=article&s='; } // 筛选条件 $where = " WHERE " . $name_field . " LIKE '%$keyword%'"; // 获取分页信息 $page = $check->is_number($_REQUEST['page']) ? $_REQUEST['page'] : 1; $limit = $dou->pager($module, ($_DISPLAY[$module] ? $_DISPLAY[$module] : 10), $page, ROOT_URL . $search_url . $keyword, $where, '', true); /* 获取搜索结果列表 */ $sql = "SELECT * FROM " . $dou->table($module) . $where . " ORDER BY id DESC" . $limit; $query = $dou->query($sql); while ($row = $dou->fetch_array($query)) { $cat_name = $dou->get_one("SELECT cat_name FROM " . $dou->table('product_category') . " WHERE cat_id = '$row[cat_id]'"); $url = $dou->rewrite_url($module, $row['id']); $add_time = date("Y-m-d", $row['add_time']); $add_time_short = date("m-d", $row['add_time']); $description = $row['description'] ? $row['description'] : $dou->dou_substr($row['content'], 150); // 生成缩略图的文件名 $image = explode('.', $row['image']); $thumb = ROOT_URL . $image[0] . '_thumb.' . $image[1]; $price = $row['price'] > 0 ? $dou->price_format($row['price']) : $_LANG['price_discuss']; $search_list[] = array ( "id" => $row['id'], "cat_id" => $row['cat_id'], "name" => $row[$name_field], "title" => $row[$name_field], "price" => $price, "thumb" => $dou->dou_file($row['image'], true), "cat_name" => $cat_name, "add_time" => $add_time, "add_time_short" => $add_time_short, "click" => $row['click'], "description" => $description, "url" => $url ); } $search_results = preg_replace('/d%/Ums', $keyword, $_LANG['search_results']); // 赋值给模板-meta和title信息 $smarty->assign('page_title', $dou->page_title('search', '', $search_results)); $smarty->assign('keywords', $_CFG['site_keywords']); $smarty->assign('description', $_CFG['site_description']); // 赋值给模板-导航栏 $smarty->assign('nav_top_list', $dou->get_nav('top')); $smarty->assign('nav_middle_list', $dou->get_nav('middle')); $smarty->assign('nav_bottom_list', $dou->get_nav('bottom')); // 赋值给模板-数据 $smarty->assign('head', $dou->head($_LANG['search'])); $smarty->assign('ur_here', $search_results); $smarty->assign('search_module', $module); $smarty->assign('product_category', $dou->get_category('product_category')); $smarty->assign('article_category', $dou->get_category('article_category')); $smarty->assign('search_list', $search_list); $smarty->display('search.dwt'); // 终止执行文件外的程序 exit(); ?>
或者直接下载并覆盖:
完成!