Have link automatically pull in relevant template

Things I have tried

I think I’m supposed to be using one of the tfile commands but haven’t gotten anything close to working. Obviously I’ve scoured the help resources on the forum but haven’t found my answer to what is probably a stupidly obvious question.

What I’m trying to do

I have a newbie-ish question.

I do research on companies. I have a main page for every company I analyze. When I begin working on a new company I have a template that creates a page that has simple links - eg [[<% tp.file title - Summary Information %>]] . Company page looks like:

Company X

[[Company X - Summary Information]]
[[Company X - Management Info]]

Currently, to complete my work, I’ll click a link and then pick the relevant template (eg, Summary Information, or Management Info). Is there a way for me to click the link and have it automatically pull up the relevant template to forego that step ??

Thanks !

1 Like

Say you have a template file named ‘Summary Information’ with the following content:

# <% tp.file.title %>

Additional company summary information goes here.

Further, say you have a template file named ‘Management Info’ with the following content:

# <% tp.file.title %>

Additional company management information goes here.

Then assuming you’ve created a new note and then entitled it, you can run the following template to fill in the main page content and create the associated sub pages.

# <% tp.file.title %>

[[<% tp.file.title %> - Summary Information]]
[[<% tp.file.title %> - Management Info]]

<%*
let tf = tp.file.find_tfile('Summary Information');
await tp.file.create_new(template = tf, filename = `${tp.file.title} - Summary Information`);
tf = tp.file.find_tfile('Management Info');
await tp.file.create_new(template = tf, filename = `${tp.file.title} - Management Info`);
-%>

Fantastic ! Thx for the clear explanation - works perfectly !

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.