I have a question about taking this one step further, but first, I just want to say thank you, thank you, thank you for this thread (original poster and everyone who helped).
I was able to take this code and incorporate it into a grocery list that I'd developed years ago and which I've been wanting to tweak. This code allowed me to group my list by the aisle. (In actuality it's more like general areas of the store.) It works great and I'm absolutely over the moon about it as I had gone down many rabbit holes before I found what I was looking for!
Now I'm wondering about tweaking it further so that it doesn't show the name of an aisle when there are no items on the list for that particular trip.
Let me 'splain:
I have dozens of tiddlers of various grocery items, each with a field called "aisle" with values like "bakery", "dairy", "frozen", "meats." I have a full list to choose from of potential grocery items and clicking an item tags them with "$purchase" (meaning "to be purchased") and they move to the current shopping list.
With help from this thread I developed the code below to show the current shopping list grouped by aisle. As I shop, checking an item on that list tags it as "$purchased" (not to be confused with "$purchase" above!) and drops it from the list.
Here is the code:
<$list filter="[has[aisle]each[aisle]sort[aisle]]">
<div class="tw-menu-list-item">
<$view field="aisle"/>
</div>
<$list filter="[!tag[$purchased]tag[$purchase]aisle{!!aisle}sort[title]]">
<div class="tw-menu-list-subitem">
<$button class="tc-btn-invisible">
<input type="checkbox"/>
<$action-listops $tags="$purchased"/>
</$button> <$link to={{!!title}}><$view field="title"/></$link>
</div></$list></$list>
The above might produce a list something like this:
bakery
bread
cookies
dairy
milk
cream
frozen
meats
chicken
sausage
etc.
As you can see, there are items under the "aisle" headers for "bakery", "dairy" and "meats"; but none under "frozen". What I want is, if there are no items from the frozen aisle (aisle="frozen") tagged with "$purchase", then suppress the header (in this case "frozen") from appearing on the list. That is, only show the header for "aisles" that contain items tagged with "$purchase".
I thought I could fix this by adding "tag[$purchase]" to the first filter but doing so caused my list to completely disappear.
My skill level is pretty basic but improving. Is there an easy fix for this? Am I missing something obvious?
Best regards and thank you for any help.
mr