これらのビューのセットのいずれかをレンダリングしたい:
- 頭
- 本体-$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 が存在しない場合、ビューが 2 回レンダリングされます。
より良い解決策はありますか?
別の言い方をすれば、body-$id1
レンダリングする前に の存在を確認してもよろしいですか?