[英]folder for view template not found
I'm again searching for the best way to do. 我再次在寻找最好的方法。 I tried a bit with partial-views, it doesn't work the template isn't found. 我尝试了部分视图,但找不到模板,这是行不通的。
Here what I did: snippet show.phtml 这是我的工作:片段show.phtml
foreach ($dcls as $dcl) :
//var_dump(get_object_vars($importdcls));
?>
<tr>
<td><?= $dcl->DCLID?></td>
<td><?= $dcl->Part_Number?></td>
<td><?= $dcl->Pad_Number?></td>
<td><?= $dcl->Pad_Issue?></td>
<td><?= $dcl->Pad_App?></td>
</tr>
<?php echo $this->partial('showpartial', ['pads'=>$pad]);?>
<?php endforeach; ?>
I saved the partial in the same folder as the show.phtml 我将局部文件保存在与show.phtml相同的文件夹中
My showpartial.phtml 我的showpartial.phtml
<?php
$this->title = "Partial";
$this->headTitle($this->titel);
?>
<p></p>
<tr>
<td><?= $pad->DCLID?></td>
<td><?= $pad->Part_Number?></td>
<td><?= $pad->Pad_Number?></td>
<td><?= $pad->Pad_Issue?></td>
<td><?= $pad->Pad_App?></td>
</tr>
In my controller I give two parameters to the view: 在我的控制器中,我给视图添加了两个参数:
return new ViewModel([
'dcls' => $this->table->fetchPartDcl($id),
'pads' => $this->padtable->fetchPadPart($id),
]);
here also my view_manager configuration: 这也是我的view_manager配置:
'view_manager' => [ //templates für den view_manager
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404', //Skript für 404 Fehler
'exception_template' => 'error/index',
'template_map' => [
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'layout/layoutlogin' => __DIR__ . '/../view/layout/layoutlogin.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
],
'template_path_stack' => [
__DIR__ . '/../view',
],
],
The error I get: 我得到的错误:
Zend\\View\\Renderer\\PhpRenderer::render: Unable to render template "showpartial"; Zend \\ View \\ Renderer \\ PhpRenderer :: render:无法渲染模板“ showpartial”; resolver could not resolve to a file 解析器无法解析为文件
because of the error message I think I have still an understanding problem. 由于出现错误消息,我认为我仍然有一个理解上的问题。 Here some questions: 这里有一些问题:
ok I added a folder partial under my view module folder. 好的,我在视图模块文件夹下添加了部分文件夹。 Now it works. 现在可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.