我已经学习了几个关于导航/部分的教程,但在显示时遇到了问题。我在view/partial模块中创建了一个文件夹,并向控制器添加了一个操作(我不认为我需要这样做)。因此,在我的布局中,我这样说:
<?php echo $this->navigation('navigation')->breadcrumbs()->setMinDepth(0)->setPartial('partial/breadcrumb.phtml'); ?>然后,当我尝试加载any页面时,它会出现以下错误:
致命错误: Zend\View\Exception\RuntimeException: Zend\View\Renderer\PhpRenderer:: render : Unable to render template“partial/breadcrum.phtml”;resolver无法解析到/var/www/html/vendor/Zend/View/Helper/Navigation/AbstractHelper.php中第170行的文件
如有任何帮助,我们将不胜感激。
更新时间:美国东部时间2017年6月18日上午9:20
我有两个页面没有显示面包屑。我认为这是因为他们有“限制”。我已经把这个放在导航中,但它似乎不起作用。有人知道这样做的正确方法是什么吗?
array(
'label' => 'View',
'route' => 'blog/view[/:post_id]',
'action' => 'view',
),
array(
'label' => 'List',
'route' => 'blog/list[/:state_id]',
'action' => 'list',
),2017年6月19日星期一更新-添加了更多导航导航:
'navigation' => array(
'default' => array(
array(
'label' => 'Home',
'route' => 'home',
),
array(
'label' => 'Blog',
'route' => 'blog',
'pages' => array(
array(
'label' => 'Maps',
'route' => 'blog/maps',
'action' => 'maps',
),
array(
'label' => 'US Map',
'route' => 'blog/us-map',
'action' => 'UsMap',
),
array(
'label' => 'View',
'route' => 'blog/view[/:post_id]',
'action' => 'view',
),
array(
'label' => 'List',
'route' => 'blog/list[/:state_id]',
'action' => 'list',
),
),
),
),
),发布于 2017-06-17 05:01:20
看起来你应该隐式地映射你正在使用的模板。所以打开你的module.config.php,这样设置模板
'view_manager' => [
'template_map' => [
// This can be any name
'partial/breadcrumb' => __DIR__ . '/../view/partial/breadcrumb.phtml',
// Other assignments
],
'template_path_stack' => [
__DIR__ . '/../view',
],
],现在,不使用setPartial('partial/breadcrumb.phtml'),而使用以下代码
setPartial('partial/breadcrumb')用于显示breadcrumbs链接的插件
虽然我没有看到你的路由配置的module.config.php。我可能错了,但我猜您在导航配置中没有使用route密钥的路由名称。如果一个路由看起来像下面这样
'application' => [
'type' => Segment::class,
'options' => [
'route' => '/application[/:action]',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],您的路径配置应位于导航数组中,如下所示
[
'label' => 'Application',
'route' => 'application', // but not /application[/:action]
'action' => 'view',
],这里,application是路由名称(路由的顶层关键字),而/application[/:action]是路由模式。
如果对你有帮助,请让我们知道!
https://stackoverflow.com/questions/44595383
复制相似问题