meteor-breadcrumb-plugin
meteor-breadcrumb-plugin copied to clipboard
Question : How to make "dynamic" parents?
Hi,
Is it possible to dynamically set the parents instead of simply using their route name? Let's say we have a collection of documents with a search page, on which the search elements are stored in the query (e.g. /documents/search?s=Some%20keywords). Search results would then be the children of the search route, using simply the search route name, breadcrumbs would look something like this:
- Documents
- Search <documents/search>
- View "Name of document" <documents/search/view/id>
But the user, when clicking the "Search" breadcrumb element, would expect to go back to the search results from where he came from.
Would there be any way to pass parameters to the parent (from the "View" route) for it to be "/documents/search?s=Some%20keywords" instead of just "/documents/search" ?
Thanks for this package anyway, it's really useful and simple!
I understand what you are saying. Unfortunately this is currently not supported. I will add this ticket as a feature request. Feel free to contribute if you find a solution for this issue.
Hey, i know it's been a while, any luck on this?
@javascriptlove I forked the package and added ability to pass function for the title and parent parameters.
Router.route('/invoices/:month', { name: "myInvoices.show", parent: function () { if (Roles.loggedInUserCan("myInvoices.index")) { return "myInvoices.index"; } else { return null; } }, title: function () { var data = this.data(); if (data) { return data.month.format('YYYY-MM'); } else { return ''; } }, waitOn: function () { var user = Meteor.user(); if(user) { return [ subsManager.subscribe('settingsForInvoice'), subsManager.subscribe('expert', user.username) ]; } }, data: function () { var wantedMonth = moment(this.params.month, 'YYYY-MM'); var userId = Meteor.userId(); if (!wantedMonth.isValid()) { return; } if (!wantedMonth.isBefore(moment(), 'M')) { return; } if (userId) { var username = Meteor.users.findOne({_id: userId}, {fields: {username: 1}}).username; if (username) { return { month: wantedMonth, expertUsername: username, }; } } }, action: function () { if (this.data()) { this.render('InvoiceShow'); } else { Router.go("NotFound404"); } } });
meteor add ziedmahdi:iron-router-breadcrumb
@monbro - Was this actually merged?
@ziedmahdi - I added your package but it does not resolve title :someRouteParam