View Single Post
Old 08-01-2023, 03:42 PM   #36
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,495
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Wiggo View Post
thx obc, already implemented.

@chaley: I see an icon if I have only one format or source. But as soon as I have two entries, no icon for format/source appears at all anymore.
It works for me. I did make a change to the add_icon() function to avoid empty icon names, but it works without that change.

Here is the booklist:
Click image for larger version

Name:	Clipboard01.jpg
Views:	142
Size:	35.4 KB
ID:	202928
The icons are on the author column.

Here is the cc_icons folder:
Click image for larger version

Name:	Clipboard02.jpg
Views:	139
Size:	47.7 KB
ID:	202929

Here is the icon rule screen:
Click image for larger version

Name:	Clipboard03.jpg
Views:	143
Size:	145.8 KB
ID:	202930

And here is the template, which is the same as yours except the one change mentioned above and changing the 'uk.png' icon name to 'beautify.png':
Code:
program:
	def add_icon(icon, val):
		if ! val then return icon fi;
		if icon == '' then icon = val else icon = icon & ':' & val fi;
		return icon
	fed;

	icon = '';
	if $languages == 'eng' then icon = add_icon(icon, 'beautify.png') fi;
	icon = add_icon(
		icon, 
		switch(
			$$#toread,
			'true', 'toread.png',
			'false', 'false.png',
			''));
	if $$#formats == 'paper' then icon = add_icon(icon, 'paper.png') fi;
	if $$#read == 'true' then icon = add_icon(icon, 'ok.png') fi;
	if $$#source == 'geniallokal' then icon = add_icon(icon, 'geniallokal.png') fi;
	if $$#source == 'wbg' then icon = add_icon(icon, 'wbg.png') fi;
	if $$#readinglist != '' then icon = add_icon(icon, 'reading_list.png') fi;
	if $$#annots != 'NONE' then icon = add_icon(icon, 'annotations.png') fi;
	if list_count($authors, '&') > 1 then icon = add_icon(icon, 'series_authors.png') fi;
	return icon
One possibility: you can't use == for multi-value columns. If #formats or #source is tags-like then you must use 'inlist'. as this:
Code:
if 'paper' inlist $#formats then icon = add_icon(icon, 'paper.png') fi;
chaley is offline   Reply With Quote