我在文章模块建了了自定义字段{$v[ganxiang]},想在做一个新页面访问这个字段和文章内容,标题,怎么在控制器添加选择新页面的指定模板,后台伪静态怎么写
总结就是文章内容可以选默认模板的同时也可以选择另外模板显示
就是原来显示/wenzhan/234.html默认模板, /wenzhan/234_new.html 新模板
以下是问AI生成的
public function index($article_id)
{
// 根据文章ID获取文章内容
$article = model('content')->where('id', $article_id)->find();
// 提取自定义标签内容
$content = $article['content'];
preg_match_all('/\[ganxiang\](.*?)\[\/ganxiang\]/', $content, $matches);
$custom_tags = $matches[1];
// 将自定义标签内容传递到模板
$this->assign('ganxiang', $custom_tags);
// 渲染模板
return $this->fetch('new/index');
}
}