Splitting information in a main file and some sub files and using different templates

Hi I am new to Obsidian and one thing I want to do with it is to store some contact information as a CRM in Obsidian.

What I’m trying to do

I would like to create a CRM.
I would like to split some of the data into seperat files.
The structure should be like:

  • Peter_Parker - Some basic information and notes about what we are talking.
  • Peter_Parker_biz - Information about my Business with Peter
  • Peter_Parker_privat - Some privat notes about Peter that should not been showen directly, when I open the main contacts page.
  • … several other topics

For Example:

  1. I create a file with the name “Peter_Parker”.
    This file will have some basic information about Peter.
  2. Now I would also like to add other files to Peter where I for examlpe save some business related information.
    That file should be named Peter_Parker_biz.
  3. The *_biz file dose not nesseserly need to be created when creating “Peter_Parker”.
    I would like to have a row in the Frontmatter:
    BIZ-Information: [[Peter_Parker_biz]]
    When I click that link, the *_biz file should be created based on an other template as the main contact.
    Perfect would be if the files are in the same folder but can base on different templates.

The *_biz file should base on an other template.

Things I have done / what works

  • I created a template for the main document and set it up together with templater.
  • When I create a new document inside of my peoples folder, the template is triggert.
  • The template inclueds some code I found here in the forum or on an noter web page (I am not 100 % sure, where I all have searched and found different things)
    If the Files name is “Untitled”, a PopUp window accours to imput the file name.
    The file is then renamed and the name is also written into the ducument.
---
fileClass: People
tags:
  - people
lastContact:
biz_data:  <% "hereShouldBeALinkToBizInformation" %>
---
<%*
	let title = tp.file.title 
	if (title.startsWith("Untitled")) {
		title = await tp.system.prompt("Title");
		await tp.file.rename(`${title}`);
	}
%>

# <%* tR += `${title}` %>


## Notes 
<% tp.file.cursor() %>

Things I have tried

Now I am stuck with two topics

  1. I tried to set up a biz-template in templater plugin.
    But I get an error, that I can’t do two templates for the same folder.
    I searched for a solution to add the different templates based on filename (file ends with _biz) or something different but did not fond a solution.
    The only way I found is a subfolder.
    For example:
    /People/ …here are the main contact information stored
    /People/Biz/ …here are the biz-information stored.
    Is there a better way?

  2. How to add the link to the biz-file into the front matter row?
    I think, I need to concatenate somehow the filename with the extention "_biz.
    But I can’t find the right syntax.

In the following example biz_data adds a link to _biz in general. That works.
Now I need to add the filename in front of _biz.
But the result of row biz_data2 showes “untitled_biz”. So, it is not the name, I write into the pop up prompt, when adding the new document.
The row biz_data3: I tried several different styles of writing, reading the templater doc (but not fully understanding), … The different versions all endet in two different ways. a) the front matter block isn’t valid any more. b) when creating a new document, templater is showing an error message.

---
fileClass: People
tags:
  - people
lastContact:
biz_data:  [[ <% "_biz" %> ]]
biz_data2: [[ <% tp.file.title %><% "_biz" %>]]
biz_data3: [[ <% title %><% "_biz" %>]]
---

Any suggestions??? :pray:

Here is something for you to start working with, which should handle your case of a main and a sub template triggered from the same template.

<%*
let title = tp.file.title
let mainTemplate
if ( title.startsWith("Untitled") ) {
  // We're now dealing with the main template stuff
  mainTemplate = "main"
  title = await tp.system.prompt("Title")
  await tp.file.rename(title)
  
} else if (title.endsWith("_biz")) {
  // Now we're dealing with the biz variant
  mainTemplate = "biz"
}

if (mainTemplate == "main") { _%>
---
fileClass: People
tags: 
  - people
lastContact:
biz: "[[<% title + "_biz" %>]]"
---

## <% title %>


### Notes
<% tp.file.cursor() %>
<%* } else if (mainTemplate == "biz") { _%>
---
tags:
  - bizStuff
---
## Biz details

<%* } _%>

This template checks whether the file is unnamed or untitled which indicates it’s a main thing and do some stuff if that’s the case. If however the template is triggered as a new file from the biz link the file already has a name and we can use this to determine that we now want to create that kind of a file.

Hopefully this make sense, and helps you on your way. Another possibility could be to include different templates using tp.file.include(), but this should work nicely as long as your template don’t get to complicated in which case it’s easy to loose track of what goes where.

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