我想渲染其中一组视图:
- 头
- 身体-$id1
- 脚丫子
或者
- 头
- 身体-$id2
- 脚丫子
哪个集合存在。
我这样做:
try {
$this->render("head");
$this->render("body-$id1");
$this->render("foot");
} catch (Exception $e) {
$this->render("head");
$this->render("body-$id2");
$this->render("foot");
}
但是head
如果 body-$id1 不存在,它会导致视图被渲染两次。
你有更好的解决方案吗?
换句话说,我可以body-$id1
在渲染之前检查它的存在吗?