Ghost: Navigation URL and Current Handlebar helpers inconsistent results
When using @blog.navigation directly (outside of a navigation.hbs partial) the {{url}} and {{current}}} handlebars helpers do not work correctly.
When using the {{navigation}} template driven helper to pull in the navigation.hbs partial the {{url}} and {{current}}} handlebars helpers work as expected.
Both cases iterated over the navigation items using {{#foreach navigation}}. In both cases {{label}} worked as expected.
Tested this on index.hbs, page.hbs, post.hbs.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 21 (10 by maintainers)
Commits related to this issue
- ✨ Attr pass-thru & full context in partial helpers refs #5162 - allow pagination and navigation partial helpers to have attributes passed through to them - e.g. {{navigation header=true}} -> {{#... — committed to TryGhost/Ghost by ErisDS 5 years ago
- Updated navigation.hbs to use {{link_class}} closes: #5162 - We no longer have to implement funky current logic, our link_class helper will do this for us - We use {{concat}} to pass an extra class ... — committed to ErisDS/Ghost by ErisDS 5 years ago
- Updated navigation.hbs to use {{link_class}} closes: #5162 - We no longer have to implement funky current logic, our link_class helper will do this for us - We use {{concat}} to pass an extra class ... — committed to TryGhost/Ghost by ErisDS 5 years ago
2 weeks ago I took another good look at this issue. The refactor needed to make the behaviour between
@site.navigationand the{{navigation}}helper the same is fairly complex, which is why this issue is still open almost 4 years later. I still don’t see that there’s a particularly clear path to it right now.In Ghost 2.17 we added the ability to pass attributes to the
{{navigation}}and{{pagination}}so that it’s possible to do{{navigation header=true}}, which will solve the main use case here, allowing for different markup in different locations.We are also experimenting with adding a link helper to handle the concept of “current”. I think between these features, we’ll have enough to cover most use cases. I’ll close this issue once the link helper goes in.
Hi @kevinansfield thanks for looking at this. I emphasized it’s still an issue because it’s been for 3 years around. I can’t use
{{navigation}}because as previous posters and how it’s explained in #8972 I’m trying to list navigation items in other parts of the website in a different form and purpose. Maybe it’s hacking the blog system but I expected the core to have persistent behaviour and I find this as a flaw. Not a priority, I can workaround this by hardcoding few things but wanted to share the use case scenario.As my issue #8972 was closed as duplicate of this one, are we going to get any kind of resolution in foreseeable future, please? Thanks.
{{> "navigation"}}is incorrect. To use the navigation helper, you need to call{{navigation}}. You do not need to specify anavigation.hbspartial unless you want to change the default output, in which case you should base your partial on the default one in Ghost: https://github.com/TryGhost/Ghost/blob/master/core/server/helpers/tpl/navigation.hbs