【发布时间】:2015-03-11 14:06:31
【问题描述】:
我正在尝试根据图像大小覆盖页面模板。当我使用 ?showtemplate 检查管道时,它说正确的模板正在呈现,但实际上它是默认的。我的控制器在下面
class Artwork_Controller extends Page_Controller {
private static $allowed_actions = array (
);
public function init() {
parent::init();
$image = $this->OrderedImages()->first();
if($image && $ratio = $image->getRatio()) {
if($ratio > 1.2 ) {
$this->renderWith("ArtworkWide");
} elseif ($ratio < 0.8) {
$this->renderWith("ArtworkNarrow");
} else {
$this->renderWith("Artwork");
}
}
}
}
如果我将 Debug 注入到它呈现在页面上的 if 块中,那么它会正确调用。但是在管道的最后一点被覆盖
【问题讨论】: