Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

Breadcrumbs::selected() method for highlighting menu items #17

Closed
d13r opened this issue Sep 1, 2013 · 1 comment
Closed

Breadcrumbs::selected() method for highlighting menu items #17

d13r opened this issue Sep 1, 2013 · 1 comment

Comments

@d13r
Copy link
Owner

d13r commented Sep 1, 2013

I'm considering adding a Breadcrumbs::selected() (or active()?) method that lets you determine whether a given page is currently active, or is a parent of this page. This would help when building navigation menus.

// In app/breadcrumbs.php
Breadcrumbs::register('home', function($breadcrumbs) {
    $breadcrumbs->push('Home', route('home'));
});

Breadcrumbs::register('kb', function($breadcrumbs) {
    $breadcrumbs->parent('home');
    $breadcrumbs->push('Knowledgebase', route('kb'));
});

Breadcrumbs::register('kb.page', function($breadcrumbs, $page) {
    $breadcrumbs->parent('kb');
    $breadcrumbs->push($page->title, route('kb.page', $page->id));
});

// In view:
Breadcrumbs::render('kb.page', $page);

// In layout:
Breadcrumbs::selected('kb.page', $page); // true
Breadcrumbs::selected('kb'); // true
Breadcrumbs::selected('somethingelse'); // false

However, this depends on render() being called before selected(), which is not ideal. (See #16 for a possible solution.)

It is also not strictly related to breadcrumbs, so perhaps it should be done in a separate package...

There is a first attempt at this in 43688d3, but it only checks the current page, not the parents.

@ghost ghost assigned d13r Sep 1, 2013
d13r added a commit that referenced this issue Sep 28, 2013
@d13r d13r removed their assignment Jun 3, 2014
@d13r
Copy link
Owner Author

d13r commented Nov 25, 2014

No longer planning to do this - there's probably a better solution anyway.

@d13r d13r closed this as completed Nov 25, 2014
@k1ng440 k1ng440 mentioned this issue Dec 14, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant