Create base template using inherited tag fields

What I’m trying to do

I have files about books with tags #Book and a tag the identifies the book in question. Lets call this the #TitleTag

I also have a file for each chapter of the book, containing the tag #Chapter and the #TitleTag from the parent book.

What I want to do is create a Base template I can insert into the book file, to list its chapters.

Things I have tried

Are too numerous to list - almost all refused to save without giving any error message.

I think I need to inherit the tags from the parent book, remove the #Book tag, and filter using the remaining #TitleTag. I don’t know how to do this.

I would be happy to move the #TitleTag in the book and chapter that identify the book, into a new properties field (by Python program!). Using this approach I have managed to get the display I want using hard coded values. Still can’t inherit using this.TitleTag though.

Any help gratefully received

Ian

You can add a base to your book notes and then filter the base by a specific tag. This gives you a list of all files with that tag. As I understand it, the #titletag is unique for each book, so the challenge is to somehow retrieve this tag from the book note in which the base is embedded. This is possible with this.. You can then filter files which partially have the same tag as the book notes.

I think it would make sense to move the #titletag into a book_id property field. If you plan to use bases more frequently, storing this information in the frontmatter is preferable, in my opinion.

1 Like

Hi Zodian,

I agree. I will be writing a program to alter the files (I have 400+ books), and then I am left with the problem of how to inherit this.book_id into the base template.

Everything I have tried so far has either not selected any files, or it is rejected as invalid syntax.

Example please.

Ian

If you add this as a filter in your base an then embedded your base in a booknote, it will show all files which have the same book_id as the book note:

files.properties.book_id == this.properties.book_id

Hi Zodian,

Unfortunately, when I came to set up the second book, the filter you get showed the chapters from both books under both titles!

Ian

Sorry it didnt work for you. I wrote it on the go and did not double check.

.properties seems to not work with .this. You can try these (both should work):

book_id == this.book_id
file.properties.book_id == this.book_id

Another approach is this, especially when using list properties:
file.properties.book_id.contains(this.book_id)

Hi Zodian,

Neither of those work for me. So I shall give up, and have a base for each book.

Then the filter is Book_ID == “Whatever”

Thanks for your efforts.

Ian