Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

nav:breadcrumbs are broken when using routes #1150

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

nav:breadcrumbs are broken when using routes #1150

mwesten opened this issue Dec 8, 2016 · 3 comments

Comments

@mwesten
Copy link

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
Copy link
Author

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
Copy link
Member

Thanks @mwesten !

@mwesten
Copy link
Author

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants