Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Problem with navigation view helper (setPartial not working properly) #91

Closed
wesperinteractive opened this issue Sep 30, 2016 · 3 comments

Comments

@wesperinteractive
Copy link

wesperinteractive commented Sep 30, 2016

Setting the module when calling setPartial has absolutely no effect.

Consider the following code:

<?php echo $this->navigation('navigation')
    ->menu()
    ->setMinDepth(0)
    ->setPartial(array('partial/menu.phtml', 'Application'));
 ?>

renderPartialModel function (https://github.com/zendframework/zend-view/blob/master/src/Helper/Navigation/Menu.php#L751) will return the $partialHelper with the following parameters:

return $partialHelper($partial[0], $model); // 'partial/menu.phtml' and $model

If we call the setPartial function with a string

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

the same happens:

return $partialHelper($partial, $model); // 'partial/menu.phtml' and $model

Why is this a problem? If you have modules with two different menu templates saved under the same name (partial/menu.phtml), then the modules loading order will decide which template is used.

@froschdesign
Copy link
Member

froschdesign commented Oct 1, 2016

Setting the module when calling setPartial has absolutely no effect.

Right, because the module option is an obsolete option parameter.

If you have modules with two different menu templates saved under the same name (partial/menu.phtml), then the modules loading order will decide which template is used.

You can specify the module name with the partial parameter:

echo $this->navigation('navigation')->menu()->setPartial('application/partial/menu');

The same for the partial helper:

echo $this->partial('application/partial/my-partial');

This is the documented behaviour.

@froschdesign
Copy link
Member

#92 removes the module option from the DocBlocks.

@froschdesign
Copy link
Member

Closing: Fixed with #92 and the correct usage of a partial is documented.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants