View Single Post
Old 02-20-2023, 09:12 PM   #9
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,109
Karma: 77213681
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
If you want to see an example of the Calibre template language in action, here's one I use:

Code:
program:

## Splitting tags
	if 
		'^(Fiction|Nonfiction|Magazines & Periodicals)' in $#booktype 
	then 
		split_tags = re($tags, '\.', ',') 
	else
		split_tags = ''
	fi;

## Removing a few unwanteds and sorting
	cleaned_tags = list_sort(list_difference(
		split_tags,
		'[Cleanup], Fiction, Nonfiction, Magazines & Periodicals, Cultures & Regions, Social Issues',
		','), 0, ',');

## Adds 'Omnibus' if present in #admintags
	if 
		'omnibus' 
	in 
		$#admintags 
	then 
		cleaned_tags  = 'Omnibus' & if cleaned_tags then ', ' & cleaned_tags fi
	fi;

	cleaned_tags
This does several things:

1. If the custom column #booktype is set to Fiction, Nonfiction, or Magazines & Periodicals, it 'splits' the tag at the periods. Fiction.Science Fiction becomes Fiction, Science Fiction. If a book doesn't have one of the defined entries in #booktype, it returns an empty value (to prevent template errors).

2. It then removes a number of selected entries from the tags and sorts the remaining results.

3. Lastly, if 'omnibus' is present in custom column #admintags, it adds Omnibus to the beginning of the string.

Quote:
Originally Posted by Sunshine82 View Post
It might be easier to explain what I am looking to accomplish in order to determine whether it is possible or if there is another way of accomplishing my goal. I am wondering if it's possible to pre-program the customized column I created entitled Genre with a comprehensive list of possible entries in advance; if so, this would allow me to create the hierarchy tree ahead of time before then assigning the designated genre path to particular books. [I have attached a screenshot to provide context.]
Take a look at the Tag Mapper.

Last edited by ownedbycats; 02-20-2023 at 09:14 PM.
ownedbycats is offline   Reply With Quote