Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 10-12-2016, 11:28 AM   #1
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
Help with Icon Rule

Hi everyone.

I need some help with an advanced rule in the icons section.

I have this rule already, but I need to add another column to it.

Code:
program:
	test(
		or(
			contains(field('#ships'), "Angela Montenegro/Jack Hodgins", 'y', ''),
			contains(field('#ships'), "Temperance Brennan/Seeley Booth", 'y', ''),

		),
		'ships (crime).png',
		''
)
I would like to add another condition which is: If my reading list column is "Interesting".

Is that possible?
Tanjamuse is offline   Reply With Quote
Old 10-12-2016, 02:48 PM   #2
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
You can have as many "contains" lines as you want in the "or". Assuming you want the same icon if #readinglist contains interesting then just add a third "contains" to the "or".

If you want different a different icon for "interesting" then you should use "first_non_empty" instead of "or" and have the "contains" return the name of the icon instead of "y". Something like
Code:
program:
	first_non_empty(
			contains(field('#ships'), "Angela Montenegro/Jack Hodgins", 'ships (crime).png', ''),
			contains(field('#ships'), "Temperance Brennan/Seeley Booth", 'ships (crime).png', ''),
			contains(field('#readinglist'), "interesting", 'someicon.png', '')
	)
chaley is offline   Reply With Quote
Old 10-12-2016, 02:53 PM   #3
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
Maybe I've not expressed myself correctly.

I need the rule to say if any of the following relationships AND on the reading list.

not

if any of the following relationships OR on the reading list.
Tanjamuse is offline   Reply With Quote
Old 10-12-2016, 03:04 PM   #4
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Something like
Code:
program:
	test(
		and(
			contains(field('#readinglist'), 'interesting', 'y', ''),
			or(
				contains(field('#ships'), "Angela Montenegro/Jack Hodgins", 'y', ''),
				contains(field('#ships'), "Temperance Brennan/Seeley Booth", 'y', '')
			),
		),
		'ships (crime).png',
		''
)
If #readinglist is a "like tags" column then you might want to "str_in_list" instead of "contains".
chaley is offline   Reply With Quote
Old 10-12-2016, 03:06 PM   #5
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
The Reading List is a Text, but with a fixed set of permitted values.
Tanjamuse is offline   Reply With Quote
Old 10-13-2016, 01:26 AM   #6
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
I've tried the newest rule and the icon is still added to all the books on the "Interesting" Reading List, not just those with the relationship tags mentioned.
Tanjamuse is offline   Reply With Quote
Old 10-13-2016, 05:15 AM   #7
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
It works for me. I don't know why it doesn't work for you.

The first screen image shows what I tested. It checks an enum column for "def". If that exists then it checks my Genre column for various things, only one of which is ever there (comics). I see the icon only on books that match, as you can see in the screen capture. The text shown with the icon is a version of the template that returns the name of the PNG you are using.
Attached Thumbnails
Click image for larger version

Name:	Clipboard02.jpg
Views:	160
Size:	53.7 KB
ID:	152329   Click image for larger version

Name:	Clipboard01.jpg
Views:	139
Size:	28.1 KB
ID:	152330  
chaley is offline   Reply With Quote
Old 10-13-2016, 05:23 AM   #8
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
The reading list column is a Text, but with a fixed set of permitted values and my relationship column has a checkmark in contains names and it's a normal tag-column.

Does that make a difference?
Tanjamuse is offline   Reply With Quote
Old 10-13-2016, 05:29 AM   #9
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,635
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by Tanjamuse View Post
The reading list column is a Text, but with a fixed set of permitted values and my relationship column has a checkmark in contains names and it's a normal tag-column.

Does that make a difference?
It shouldn't, the rule looks right. Could you get a screenshot of the rule... and the result in the library, where the fields are shown? Perhaps it can make clear the problem.
Terisa de morgan is offline   Reply With Quote
Old 10-13-2016, 05:29 AM   #10
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Tanjamuse View Post
The reading list column is a Text, but with a fixed set of permitted values and my relationship column has a checkmark in contains names and it's a normal tag-column.

Does that make a difference?
In my example, #enum is a column like yours, with a fixed set of values. The #genre column is like yours, text, like tags. It does not have the "contains names" box checked, but that shouldn't make a difference unless you were treating it as a list, which you are not.

Carefully check the parenthesis and commas in your expression. You can use the template tester (available in Preferences / Toolbars) to help debug.
chaley is offline   Reply With Quote
Old 10-13-2016, 05:36 AM   #11
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
I have discovered the problem.

In my reading list I have 3 definitions: Uncertain,Interesting,Uninteresting.

The icon rule also selects those stories on the Uninteresting list.
Tanjamuse is offline   Reply With Quote
Old 10-13-2016, 05:38 AM   #12
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Tanjamuse View Post
I have discovered the problem.

In my reading list I have 3 definitions: Uncertain,Interesting,Uninteresting.

The icon rule also selects those stories on the Uninteresting list.
"Contains" uses regex patterns, so use an anchored pattern
Code:
contains(field('#readinglist'), '^interesting$', 'y', ''),
chaley is offline   Reply With Quote
Old 10-13-2016, 05:40 AM   #13
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,635
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by chaley View Post
"Contains" uses regex patterns, so use an anchored pattern
Code:
contains(field('#readinglist'), '^interesting$', 'y', ''),
An explanation:
  • ^: Beginning of line
  • $: End of line

In this case, as it is only a value, it matches.
Terisa de morgan is offline   Reply With Quote
Old 10-13-2016, 05:42 AM   #14
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
That did the trick. Thanks both of you for the help.
Tanjamuse is offline   Reply With Quote
Old 10-13-2016, 03:13 PM   #15
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
If I wanted to use this rules on all the ships except those mentioned, what would the rule be then?
Tanjamuse is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
One File to Rule Them All ? storax Workshop 3 08-14-2013 08:12 PM
One device to rule them all BeccaPrice General Discussions 95 08-17-2012 06:15 AM
The 5 finger rule. AlexGrama General Discussions 73 02-26-2012 05:19 AM
ID: Rule Above and Below dezignlady ePub 5 07-12-2011 11:40 PM
Will One Device Rule Them All... Or Not thymaster General Discussions 65 11-23-2010 01:19 PM


All times are GMT -4. The time now is 02:07 PM.


MobileRead.com is a privately owned, operated and funded community.