Mohammad, 

This also solves the thing I was just working on, and that is hiding stars 
when there is no rating. Nice!

Thanks to both of you for helping with this. I've got so much to learn.

Jack



On Monday, May 10, 2021 at 3:15:02 PM UTC-4 Mohammad wrote:

> Hi Jack,
>  If you want to keep your own solution then go with Soren! 
> What Soren provided shows the trick!
>
> Another solution is to  change the content of your template (
> https://rudimentarylathe.wiki/#%24%3A%2Fplugins%2Faaldrich%2Ftables%2Ftemplate%2Fbody%2Frate
> )
> with the below wikitext
>
> \define ratingFilter() [range[1,$(rating)$]]
>
> <$list filter="[<currentRecord>has[rating]get[rating]]" variable=rating 
> emptyMessage="""<td></td>""">
> <td>
> <$list filter=<<ratingFilter>> > {{$:/core/images/star-filled}}</$list>
> </td>
>
>
> Also in the example https://rudimentarylathe.wiki/#My%20Books%20-%20TEST 
> clear extra wikitext, delete the macro getSras and just
>
> Working on a better way to render the list of books.
>
> Here's a failed attempt using ~TiddlyTables:
>
> <<table>>
>
>
> Tested on your wiki, I get the below result
>
> [image: image.png]
>
>
>
> Best wishes
> Mohammad
>
>
> On Mon, May 10, 2021 at 11:19 PM Jack Baty <ja...@baty.net> wrote:
>
>> Mohammad,
>>
>> Thank you! Your sample helps me understand how to do this kind of 
>> rendering, though, which is great. (I still seem to overlook using $list 
>> for seemingly everything). 
>>
>> I'm using Tobias' rate plugin for setting and displaying the ratings on 
>> individual tiddlers and it works well. 
>>
>> I'm now working on getting the macro to run correctly when used in a 
>> template in the TiddlyTables plugin. I've tried every combination I can 
>> think of in the column's view template but can't get the macro to "see" the 
>> rating value for each row. If I render a table "by hand" it works fine.
>>
>> Maybe someone can spot an obvious error in my implementation here:
>>
>>   https://rudimentarylathe.wiki/#My Books - TEST
>>
>> There's a custom template for rating that contains the following:
>>
>> ```
>> <td>
>> <$macrocall $name="getStars" numstars={{!!rating}} />
>> </td>
>> ```
>> I feel like I'm going to need "<<currentRecord>>"  somewhere but can't 
>> seem to figure out where.
>>
>> Anyway, thanks for the leg up. I can fall back to my hand-rendered table 
>> easy enough if I can't figure out how to use it in TiddlyTables.
>>
>>
>> On Monday, May 10, 2021 at 10:52:34 AM UTC-4 Mohammad wrote:
>>
>>> Hi Jack,
>>>  The Vote plugin from Kooma Library do rating and you can retrieve stars 
>>> and compare and analyse!
>>>
>>> But if you want your simplest solution the below is one! Wait for 
>>> better, I sure you will get alternatives
>>>
>>>
>>> \define getStars() <$list filter="[range[1,$(vl-stars)$]]">*</$list>
>>>
>>> <$list filter="[all[current]has[rating]get[rating]]" variable="vl-stars">
>>> <<getStars>>
>>> </$list>
>>>
>>>
>>> The above can be used inside a vietemplate if you like to have stars 
>>> automatically displayed!
>>> Adopt if you like to use a table! for a specific tiddler!
>>>
>>>
>>>
>>>
>>> Best wishes
>>> Mohammad
>>>
>>>
>>> On Mon, May 10, 2021 at 7:03 PM Jack Baty <ja...@baty.net> wrote:
>>>
>>>> I have a "rating" field that contains a number from 1-5.
>>>>
>>>> When generating a table (or list) of rated tiddlers, I want to display 
>>>> the rating as a number of stars. e.g. ★★ or ★★★ etc corresponding to the 
>>>> value in rating for each tiddler.
>>>>
>>>> For the life of me, I can't figure out how to do this. Is there some 
>>>> form of string math like "★*rating"? Do I need to choose from a 
>>>> pre-defined 
>>>> list? Do I need to just give up and change the field to contain the actual 
>>>> stars? I'm stumped, sorry.
>>>>
>>>> Jack
>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>> 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 tiddlywiki+...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/tiddlywiki/cc78aa80-95c1-4608-aad8-f41c4d2959b9n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/tiddlywiki/cc78aa80-95c1-4608-aad8-f41c4d2959b9n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> 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 tiddlywiki+...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/tiddlywiki/90025997-7113-4d36-82de-efc4c73f5443n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/tiddlywiki/90025997-7113-4d36-82de-efc4c73f5443n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/6f528d38-aa4c-4969-a2cb-4e168479557dn%40googlegroups.com.

Reply via email to