First of all, thank you all for your efforts in this forum.
I have this situation:
- mysite.com/authors (list of authors)
- mysite.com/author/1 (author 1)
- mysite.com/book/1 (book 1 of author 1)
- mysite.com/cart/1 (cart page of book 1 of author 1)
I need an url like this:
mysite.com/author/1/1/cart
but I don't want nested template (every page is different and I don't want same info in many page).
Is there a way to have that URL?
My actual router.js is this:
Router.map(function() {
this.route('index', {path: '/'});
this.route('login');
this.route('authors', {path: '/authors'});
this.route('author', {path: '/author/:author_id'});
this.route('book', {path: '/book/:book_id'});
this.route('cart', {path: '/cart/:cart_id'});
});
You have two options:
Multiple dynamic segments
Just don't nest your routes but have multiple dynamic segments. Thats possible:
This will give you a route like this:
/cart/1/Athis will render thecartroute with the author 1 and the cart ANest but just don't put anything into the parent route
So you can have this router:
Now your problem is that if you put the author data into the
/authorroute its also visible on theauthor.cartroute. But a simple solution is to keep theauthorroute empty, with just{{outlet}}as the template and put your author stuff into theauthor.indexroute.This will give you routes like this:
/author/1this will render theauthor.indexroute with the author 1/author/1/cart/Athis will render theauthor.cartroute with the author 1 and the cart A