Browse Source

搜索页获取pdf链接更改

master
xiaodong 1 week ago
parent
commit
52fbad735d
  1. 18
      public/themes/website/1/zh/demo/single_search.html

18
public/themes/website/1/zh/demo/single_search.html

@ -144,7 +144,23 @@
$sr_cid = $vo['category_id'] ?? ($vo['category'][0]['id'] ?? 0); $sr_cid = $vo['category_id'] ?? ($vo['category'][0]['id'] ?? 0);
$sr_thumb = is_array($vo['thumbnail'] ?? null) ? ($vo['thumbnail']['url'] ?? '') : ''; $sr_thumb = is_array($vo['thumbnail'] ?? null) ? ($vo['thumbnail']['url'] ?? '') : '';
$sr_url = hcUrl('detail/index', ['id' => $vo['id'], 'cid' => $sr_cid]); $sr_url = hcUrl('detail/index', ['id' => $vo['id'], 'cid' => $sr_cid]);
$sr_file = trim((string)($vo['url'] ?? ''));
// PDF文件链接从 hc_article.resource_download 获取(多附件字段,存的是附件ID的JSON数组)
$sr_file = '';
if (($vo['sr_kind'] ?? '') === 'download') {
$articleRow = \think\facade\Db::table('hc_article')->where('sub_id', $vo['id'])->field('resource_download')->find();
if (!empty($articleRow['resource_download'])) {
$attachIds = json_decode($articleRow['resource_download'], true);
if (is_array($attachIds) && !empty($attachIds)) {
$firstAttach = \think\facade\Db::table('hc_attachment')->where('id', intval($attachIds[0]))->field('url')->find();
if (!empty($firstAttach['url'])) {
$sr_file = trim($firstAttach['url']);
}
}
}
}
if ($sr_file === '') {
$sr_file = trim((string)($vo['url'] ?? ''));
}
$has_sr_file = $sr_file !== ''; $has_sr_file = $sr_file !== '';
$sr_title = $vo['title'] ?? ''; $sr_title = $vo['title'] ?? '';
$sr_type_name = $vo['sr_tab_name'] ?? '内容'; $sr_type_name = $vo['sr_tab_name'] ?? '内容';

Loading…
Cancel
Save