让我们假设控制器中的以下代码:
$this->view->addScriptPath('dir1/views/scripts');
$this->view->addScriptPath('dir2/views/scripts');
$this->render('index.phtml');
其中 dir1/views/scripts 包含 2 个文件:
-index.phtml
-table.phtml
和 dir2/views/scripts:
-table.phtml
现在,它将在 dir1 中呈现 index.phtml,因为 dir 2 没有 index.phtml。
Index.phtml 看起来像:
<somehtml>
<?= $this->render('table.phtml') ?>
</somehtml>
这就是我开始困惑的地方。我希望它能够呈现添加到脚本路径堆栈的最后一个目录中的 table.phtml,但事实并非如此。
我的问题有简单的解决方案/解释吗?