View Single Post
Old 08-11-2016, 11:11 AM   #3
readin
Enthusiast
readin is on a distinguished road
 
Posts: 25
Karma: 50
Join Date: Apr 2016
Device: calibre
Quote:
Originally Posted by chaley
METHOD 3 - Single advanced rule for column icons ... The following template, adapted from yours to use a column and icons I have available, works...
Thank you chaley, that works beautifully.

I modified it to display blank icons if a match is not found. This aligns the icons so that they are always displayed in the same position.

Code:
program:
	list_union(
		'',
		strcat(
			contains(field('#own'), 'p', 'book.png:', 'blank.png:'),
			test(field('series'), 'series.png:', 'blank.png:'),
			contains(approximate_formats(), 'LNK', 'folder.png:', 'blank.png:'),
		), ':')
I've attached a screenshot of the result below.


Quote:
Using the template tester to debug the function(s) is faster than changing the template in a custom column. I have added it (the tester) to the right-click context menu for the main library.
Nice! I gave it a keyboard shortcut.

Quote:
METHOD 4 - User-defined template functions ... a template function that does what I think you are asking for is...
Thanks very much!

I am now using the has_ebook() function you provided as follows:

Preferences > Look and Feel > Column coloring:

Advanced Rule for <All Columns>:
Code:
program:
	test(has_ebook(), '', 'red')
Using these two methods -- a template for composed icons, and a function for coloring books red -- is probably much more efficient than using a bunch of basic rules, especially because I will be adding a few more icons and ebook formats to them.

Even though I've dabbled in programming over the years, I don't know Python, and there's a lot in your function that I don't understand. Creating a function instead of a template for the composed icons may be beyond me.

So thanks for helping me to get this far.
Attached Images
 

Last edited by readin; 08-11-2016 at 11:30 AM. Reason: correction
readin is offline   Reply With Quote