[solved] Help with two different subscriptions to the same collection


#1

I’m having a small issue with my templates/subscriptions. I have a template that lists orders from a collection. I have the publication set up for filters so you search orders by a status property. This works great.

But the issue starts here, within the same template I have a list of all possible statuses that you can click to show a list of the filtered data. I want the status link to show a count() of the number of entries that include that status. But the count() only shows for the currently subscribed data, and shows 0 for all other statuses, even ones that should show a count. This is because the data is not published unless it has been selected. Which is definitely the expected outcome. But I want it to be able to show all counts.

I tried putting the status filters into it’s own separate template. So my subscription is set up like this:

Template.OrderFiltersList.created = function () {
   this.subscribe('all_orders');
};

And this now subscribes to ALL orders to be counted properly.

But now here is the NEW issue…now on the other (parent) template, it is showing ALL orders instead of the filtered orders.

It’s set up like this:

<template name="OrderList">
  {{> OrderFiltersList}}

  {{#each filteredOrders}}{{/each}}
</template>

OrderList gets it’s subscription from it’s route for the filteredOrders.

So basically…why can OrderList access OrderFiltersList’s subscriptions?? And how can I limit it for just that template.

-Meteor newb :stuck_out_tongue:


#2

Well. I just solved my own problem. For my orders list I was finding all of the data in my helper. :smile:
So now Im using Orders.find({ status: filter }); instead of Orders.find();