新闻模块 - 代码示例
获取新闻列表
// 使用 ContentService
$news = ContentService::getNewsByCat($cid, 10);
// 使用助手函数
$news = getNewsByCat($cid, 10);
// 使用 Model
$news = NewsModel::where('delstatus', 0)
->where('checked', 1)
->order('id', 'desc')
->limit(10)
->select();
根据新闻标签获取相关产品
// 使用助手函数
$related = getRelatedNews($id, 6);
// 使用 ContentService
$related = ContentService::getRelatedProductsByNewstags($id, 6);
新闻列表数据
| ID | 标题 | 点击数 | 创建时间 |
|---|---|---|---|
| 14 | 安全生产规范 | 0 | 2026-07-15 07:46 |
| 13 | 环保政策解读 | 0 | 2026-07-15 07:46 |
| 12 | 新材料研发进展 | 0 | 2026-07-15 07:46 |
| 11 | 化工行业最新动态 | 0 | 2026-07-15 07:46 |
| 10 | 技术革新报告 | 0 | 2026-07-15 07:46 |