<?php
/**
 * 芋头CMS
 * ============================================================================
 * 版权所有 2016-2028 沅陵县乌托邦网络服务有限公司，并保留所有权利。
 * 网站地址: http://www.yutoucms.cn
 * ----------------------------------------------------------------------------
 * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷。
 * ============================================================================
 * Author: 芋头 <mxgsf@qq.com>
 * Date: 2026-5-30
 */
if (!defined('ROOT_PATH')) { exit('Access Denied'); }

$pageTitle = $channel['channel_name'] ?? '新闻资讯';
require_once __DIR__ . '/../_header.php';
$allChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = 23 AND channel_type = 1 AND is_show = 1 ORDER BY list_order ASC, id ASC");
$curChannelId = isset($_GET['channel_id']) ? intval($_GET['channel_id']) : 0;
$currentNavId = $curChannelId ?: intval($channel['id'] ?? 0);
$sql = "SELECT a.*, c.channel_name FROM {$db->table('article')} a LEFT JOIN {$db->table('channel')} c ON a.channel_id=c.id WHERE a.status=1";
$params = [];
if ($curChannelId > 0) {
    $sql .= " AND a.channel_id = ?";
    $params[] = $curChannelId;
}
$sql .= " ORDER BY a.create_time DESC LIMIT 100";
$allArticles = $db->fetchAll($sql, $params);
?>
<div class="bannern c" style="background:url(<?php echo $site['template_dir']; ?>static/upload/image/20220801/1659354277651388.jpg) no-repeat center;"></div>
<div class="n_cont c">
  <div class="jz c">
    <div class="ny_nav" id="my_sticky">
      <div class="wjssbt c"><?php echo htmlspecialchars($channel['channel_name'] ?? '新闻资讯'); ?></div>
      <ul class="wjsndh c">
        <?php foreach ($allChannels as $ch): ?>
        <li class="c"><a href="?m=article&channel_id=<?php echo $ch['id']; ?>"<?php echo $currentNavId === intval($ch['id']) ? ' style="background:#108dee;color:#fff;"' : ''; ?>><?php echo htmlspecialchars($ch['channel_name']); ?> <span>></span></a></li>
        <?php endforeach; ?>
      </ul>
      <div class="search_l">
        <form method="get" action="<?php echo getUrl('search'); ?>">
          <input type="hidden" name="m" value="search">
          <input type="text" class="ip" name="keyword" placeholder="请输入关键字">
          <input type="submit" class="btn" value="搜索">
        </form>
      </div>
    </div>
    <div class="ny_zqw ny_zqw_chb">
      <div class="nw_top"><span class="top_tzbt l"><?php echo htmlspecialchars($channel['channel_name'] ?? '新闻资讯'); ?></span><span class="top_mbx r am-icon-home">您的位置： <a href="<?php echo getUrl('home'); ?>">首页</a> >> <a href="<?php echo getUrl('channel', intval($channel['id'] ?? 0)); ?>"><?php echo htmlspecialchars($channel['channel_name'] ?? '新闻资讯'); ?></a></span></div>
      <div class="h10"></div>
      <div class="bjbld">
        <ul class="wjzlb">
          <?php foreach ($allArticles as $a): ?>
          <li class="c"><a href="<?php echo getUrl('article', $a['id']); ?>" title="<?php echo htmlspecialchars($a['title']); ?>"><span class="wjll l"><span class="wjlbt"><i class="am-icon-angle-right"></i><?php echo htmlspecialchars($a['title']); ?></span><span class="wjlrq"><?php echo date('Y-m-d', $a['create_time']); ?></span></span></a></li>
          <?php endforeach; ?>
        </ul>
      </div>
    </div>
  </div>
</div>
<?php require_once __DIR__ . '/../_footer.php'; ?>
