New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nav:breadcrumbs are broken when using routes #1150

Closed
mwesten opened this Issue Dec 8, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@mwesten

mwesten commented Dec 8, 2016

Expected behaviour

Display the breadcrums for the URL-parts that are actual pages.

Actual behaviour

Breadcrumbs are shown for all URL-parts even if the pages don't exist (as in routing or vanity urls).

Steps to reproduce

Install Statamic 2.1.18 (in my case on http://breadcrumbs.dev )
Add the following to /sites/themes/redwood/layouts/default.html

{{ nav:breadcrumbs }}
  {{ title }} - 
{{ /nav:breadcrumbs }}

added snippet

Now go to the following URLs:
http://breadcrumbs.dev/about This looks like it should
about breadcrumb

http://breadcrumbs.dev/blog This looks like it should too
blog breadcrumb

Now go to to http://breadcrumbs.dev/blog/tags/harry-potter
breadcrumb tag

or http://breadcrumbs.dev/blog/2015/07/22/fire-fire-looking-forward-to-hearing-from-you
breadcrumb blogpost

it shows Home for all routed paths that aren't actual pages

Server configuration

Operating system: OSX 10.11.6

Web server: Apache 2.4.18

PHP version: 7.0.4

Statamic version: 2.1.18

Updated from an older Statamic or fresh install: Fresh Install

List of installed addons: none

@mwesten

This comment has been minimized.

mwesten commented Dec 8, 2016

Hmmmm digging into it, it seems that code is there that should fix this (/statamic/bundles/Nav/NavTags.php line 128 and further).

nav:breadcrumbs current

Looking into it, the check that is done, tries to lookup the url and fetch the respective object containing data. The problem in the current situation is that the $default_segment_uri of the non-existent URL-parts are NULL values and fetching the Content of a NULL item returns an object, so all URL-parts are rendered as bredcrumbs.

Changing the code to this however checks if the $default_segment_uri is_null() and if it does, skips over it. This seems to do the trick !
nav:breadcrumbs working

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Dec 8, 2016

Thanks @mwesten !

@mwesten

This comment has been minimized.

mwesten commented Dec 8, 2016

np ;) hope this works under all circumstances... just tested a couple of scenarios, but seems to hold up...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment