Aldeed:Tabular working with Flow Router


#1

Hi,

I want to filter my Aldeed:Tabular table based on the URL, e.g. if someone enters mysite.com/productA, the table should filter by productA. I followed the Aldeed:Tabular instructions to filter a collection like below:

Template.loginstemplate.helpers({
    'selector': function() {
        return {Recordtype: "A"};
    }
})

And in my HTML file:

{{> tabular table=TabularTables.Logins selector=selector class="table table-bordered" width="100%"}}

How can I make Flow Router change the selector function to different products? e.g. the URL mysite.com/productB should cause the selector function to return:

return {Recordtype: "B"};

My Flow Router routes.js looks like this right now:

FlowRouter.route('/logins/show', {
action: function() {
BlazeLayout.render("mainLayout", {content: "loginstemplate"});
 }
});

#2

You could use FlowRouter to get the product type from the url:

FlowRouter.route('route/:product', { name: 'Product', action(params, queryParams) { BlazeLayout.render('mainLayout', {content: 'yourView'}); } });

Then get the product within your helper with:

FlowRouter.getParam('product')

Which will get you whatever comes after “route/” in your url.