1
votes

I have followed a couple tutorials on navigation/partials and am having issues with it displaying. I created a folder in the module for view/partial and have added a action to the controller (don't think i need this). So in my layout i call out this:

  <?php echo $this->navigation('navigation')->breadcrumbs()->setMinDepth(0)->setPartial('partial/breadcrumb.phtml'); ?>

Then when i try to load the any page it comes up with this error:

Fatal error: Zend\View\Exception\RuntimeException: Zend\View\Renderer\PhpRenderer::render: Unable to render template "partial/breadcrumb.phtml"; resolver could not resolve to a file in /var/www/html/vendor/Zend/View/Helper/Navigation/AbstractHelper.php on line 170

Any help would be most appreciated thanks in advance.

Update: June 18 2017 9:20am EST

I have two pages that do not show breadcrumbs. I am thinking that it is because they have 'constraints'. I have put this in navigation but it does not seem to work. Does anyone know what the correct way to do this is?

            array(
                'label' => 'View',
                'route' => 'blog/view[/:post_id]',
                'action' => 'view',
            ),
            array(
                'label' => 'List',
                'route' => 'blog/list[/:state_id]',
                'action' => 'list',
            ),

Updated Monday June 19 2017 - added more navigation Navigation:

    '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',
             ),
          ),
       ),
    ),
 ),
1

1 Answers

0
votes

It seems your should implicitly map the template that you are using for this. So open up your module.config.php, set up the template thus

'view_manager' => [

    'template_map' => [
        // This can be any name
        'partial/breadcrumb' => __DIR__ . '/../view/partial/breadcrumb.phtml',

        // Other assignments
    ],
    'template_path_stack' => [
        __DIR__ . '/../view',
    ],        
],

Now instead of setPartial('partial/breadcrumb.phtml') use the following one

setPartial('partial/breadcrumb')

Addition for showing breadcrumbs links:

Though I did not see your module.config.php for route configuration. I may be wrong but I am guessing you are not using the route name for the route key in the navigation configuration. If a route looks like the below

'application' => [
    'type'    => Segment::class,
    'options' => [
        'route'    => '/application[/:action]',
        'defaults' => [
            'controller' => Controller\IndexController::class,
            'action'     => 'index',
        ],
    ],
],

your route configuration should be in the navigation array as the following

[
    'label' => 'Application',
    'route' => 'application', // but not /application[/:action]
    'action' => 'view',
],

Here application is the route name (top key of a route) while /application[/:action] is the route pattern.

Let us know if it helps you!