View Single Post
Old 02-06-2023, 04:15 PM   #499
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,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
New question:

I created several user-categories to group the entries in taglike #fanficcat. (For several reasons, I prefer to leave the column itself as nonhierarchical entries.)
Attachment 199438

To find books that have entries not present in the categories, I search for #fanficcat:true AND @Fanfiction.Fandoms:.false. Is it possible to also check this with a template?

EDIT:

Code:
program: 
	if 
		$#fanficcat 
		&& !'Fandom' inlist user_categories() 
	then 
		'aaaa' 
	fi
That is one way, probably the best. However, you could use
Code:
ids = book_values('id', '#fanficcat:true AND @Fanfiction.Fandoms:.false', ',', 0)
then check if $id is in the returned list. This will be slow if it is used in a composite, OK in an action chain or a template search.


Quote:
Originally Posted by ownedbycats View Post
In the book list, there's a stray comma at the beginning of this composite taglike. Where is it coming from?

EDIT: It goes away if I run the strcat through list_remove_duplicates.
It happens because there is always a comma at the end of the list, creating an empty item. When the list is sorted to be displayed the empty item is less than everything so it goes to the front.

The list_remove_duplicates() function also removes empty items.

The right fix is to remove the comma at the end with something like
Code:
re(v, ',$', '')
chaley is offline   Reply With Quote