zendframework / zend-navigation

Navigation component from Zend Framework
BSD 3-Clause "New" or "Revised" License
20 stars 25 forks source link

Zend Navigation with Zend Expressive - localization ? #64

Closed unnamed666 closed 6 years ago

unnamed666 commented 7 years ago

hi, i have a little question about Zend Navigataion. After following cookbook tutorial about setting locale without url param (https://docs.zendframework.com/zend-expressive/cookbook/setting-locale-without-routing-parameter/) i am a bit confused so maybe someone can help me here.

If i enter url like local.com/en/some-page my locale is set to english and all urls created with UrlHelper get '/en' part prepended but Zend Navigation is still rendering url without that '/en' part.

What should i do to make Zend Navigation prepend that '/en/' part to all created links just like UrlHelper? ps. i am using froschdesign/zend-navigation - feature/expressive-support branch

froschdesign commented 7 years ago

@unnamed666

my locale is set to english and all urls created with UrlHelper get '/en' part prepended but Zend Navigation is still rendering url without that '/en' part.

The page type Expressive doesn't use the Zend\Expressive\Helper\UrlHelper to generate the URLs. The Router is used. The ZF router also interacts with a base URL, maybe this is a solution.

froschdesign commented 7 years ago

@unnamed666 I worked on a solution to fix the problem. I will update my feature/expressive-support branch in the next days.

Thanks for your patience!

froschdesign commented 6 years ago

@unnamed666 This fix your problem:

https://github.com/froschdesign/zend-expressive-navigation/blob/master/test/Page/ExpressivePageTest.php#L112-L127

froschdesign commented 6 years ago

The support of zend-expressive will not be a part of this component. It is include a new component "zend-expressive-navigation" and also the UrlHelper with the base path.

Thanks for the hint! 👍