I've used a slightly different structure, to leverage the tag and list fields.
Grocery tiddlers are tagged with "Item", and have the following special fields: tags: (one or more of) Item Selected sections: (field indicating the section where the item can be found) retailers: (list field with retailers) An item tagged with "Item" is a grocery/shopping item. An item also tagged with "Selected" is selected for the current shopping list / week. Items tagged "Recurring" will appear on the recurring list. There is a special tiddler Retailers that has a list of all retailers in its list field. There is a special tiddler Sections that has a list of all sections in its list field. A view template helps you select or remove retailers. There is a lister tiddler that lists your items, as you asked. Here is a screenshot: The attached contains the starter kit. Back up any work you have started. Or better yet, use a fresh empty TW file. Download the attached. Drag and drop into your TW file (a green bar should appear at the top). Import the tiddlers. There are many improvements that could be made. For instance, making each item in the grocery list a link might be useful. It's left as an exercise to add "sections" to the grocery view template. I should probably post this in it's own TW page somewhere. On Thursday, March 19, 2020 at 9:09:13 AM UTC-7, David wrote: > Mark, > > So would each tiddler become like a row in a database table? > > And would the columns of that row be colon separated values like a data > tiddler? Example: > > Tiddler Name: $:/data/ShoppingItems/Milk > > Tiddler content: > > buyItThisWeek: yes > recurringWeeklyItem: yes > storeSection: Dairy > atSamsClub: yes > atLidl: yes > > And then could you throw together some code to give me a list of all the > "data" tiddlers with a prefix of "$:/data/ShoppingItems/" that have a > "buyItThisWeek" value of "yes"? > > And bonus points for having the list sorted by store section. > > I think that would lay down a nice groundwork for me to build on and use > as a pattern as I study the listWidget. > > Thanks so much if you can! > > > On Monday, March 16, 2020 at 12:49:07 PM UTC-4, Mark S. wrote: >> >> I think newcomers sometimes gravitate towards the data tiddler, because >> it seems familiar. But really, the main data element in TW isn't the data >> tiddler, which are pretty limited, but the tiddler themselves. The problem >> with using a data tiddler is that it will record a single bit of >> information for each item. Like "buy/don't buy". But what if you have one >> item that you can get from two different places? Or if you want to indicate >> what kind of product it its (produce, hardware, canned, cleaning, etc.) ? >> >> The best thing to learn is the list widget, and the filters it uses. >> >> I use a TW grocery list every week. I suppose I should sanitize it and >> post a version. I haven't kept it up to 5.1.20 capabilities ... but >> sometimes "good enough" is the enemy of "perfect." >> >> Ok, back to your question. >> >> Let's say you have a data tiddler like: >> >> ShoppingSamsClubData >> >> with >> >> <https://tiddlywiki.com/#> >> Aardvarks: yes >> >> Kittens: no >> Puppies: yes >> >> Then in a tiddler you can put: >> >> <$tiddler tiddler="ShoppingSamsClubData"> >> <$list filter="[all[current]indexes[]sort[]]" variable=item> >> <$checkbox index=<<item>> checked="yes" unchecked="no"/> <<item>><br/> >> </$list> >> </$tiddler> >> >> >> And it will give you a dynamic list like (you should see a screen shot here): >> >> >> I guess if all you ever want is to shop at Sam's club, then you're good >> to go! >> >> HTH >> >> On Monday, March 16, 2020 at 7:02:36 AM UTC-7, David wrote: >>> >>> Summary: >>> >>> I'd like to have a list of checkboxes, for a grocery list, that pull >>> data from a DataTiddler. >>> >>> >>> Detail: >>> >>> I have items I shop for every week and I thought I'd create a tiddler to >>> allow me to uncheck and check items as I shopped. >>> >>> >>> - I'd like the *state *of the checkboxes to be stored somehow, I'm >>> not picky where. Simpler may be better. >>> - I'd like it to pull the list of items from a *DataTiddler*. I >>> think separating the display code from the data would be nice, and I can >>> also learn about DataTiddlers at the same time. I'm thinking I don't >>> care >>> if the state of each checkbox is stored in the DataTiddler or in the >>> tiddler with the logic. I guess ideally it would be in the DataTiddler, >>> but at this point if it is simpler I don't have to. I have an example >>> where the state of each box is stored in the logic tiddler's field, >>> which >>> works. >>> - If the data could be stored in more of a CSV style, that would be >>> nice as well, but not essential. >>> >>> I've done a good bit of searching on DataTiddlers and indexes and have >>> found some help, but not a lot. Here's some code that gives me what I >>> want, but obviously I'd rather not have to add more checkbox commands for >>> each new item I put in the dataTiddler. I know I can loop over this >>> somehow, right? >>> >>> But I was unable to find how to successfully loop over the keys in a >>> Dictionary Tiddler. >>> >>> This works, but is not dynamic... >>> >>> <$checkbox field="item1" >>> checked='val1'>{{ShoppingSamsClubData##item_01}}</$checkbox> >>> <$checkbox field="item2" >>> checked='val2'>{{ShoppingSamsClubData##item_02}}</$checkbox> >>> >>> And here are the contents of the data tiddler.... >>> >>> item_01: Rice >>> item_02: Milk >>> >>> *type: application/x-tiddler-dictionary* >>> >>> >>> -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/4e5416d1-6540-41f9-bede-87e74393bdc2%40googlegroups.com.
grocery-list-manager.json
Description: application/json

