First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.
What I’m trying to do
I am trying to use as Bases file in an preview of a linked file. I need to access the properties of the parent file for this.
I have a meeting template with a fixed footer. Right now, this footer is part of every meeting Note, but I want to have some #include like functionality so I only need to update the footer in 1 place.
I can use ![[footer]] to preview, which works fine.
But, I want to add some Bases functionality there. Specifically, I want to see a list of all related notes, based om the subject property in my frontmatter.
directly in the Note, it works fine. But, when I put it in a separate file to be previewed, it of course filters based on the subject field in footer instead of in the parent file.
Clearly, this.subject is not the right clause. I need something like parent.subject , but I have no idea what to put here.
Things I have tried
I tried finding anything about the data model but cannot find anything that helps me.
Then you have the footer and the base in your notes, this should work correctly and you can do changes to the base in one place and it will affect all notes.
However, I just found out that my footer has the same problem.
I use the following code in the footer:
// prevnextsubject.js
// Combines prev/next for project and prev/next for subject
// Subjectline
var prevSubjectPath = dv.pages().where(p =>
p.subject === dv.current().subject &&
p.file.ctime < dv.current().file.ctime).sort((p => p.file.ctime),
"desc")
.limit(1)
.map(p => p.file.path);
var nextSubjectPath = dv.pages().where(p =>
p.subject === dv.current().subject &&
p.file.ctime > dv.current().file.ctime).sort((p => p.file.ctime),
"asc")
.limit(1)
.map(p => p.file.path);
var prevSubjectPathString = prevSubjectPath.first();
var nextSubjectPathString = nextSubjectPath.first();
var combinedSubjectLine = "";
// dv.span("[" + dv.fileLink(nextSubjectPathString, false, nextSubjectPathString) + "]");
if (prevSubjectPathString) {
combinedSubjectLine = combinedSubjectLine + dv.fileLink(prevSubjectPathString, false, " <<< Previous in Subject");
}
else {
combinedSubjectLine = combinedSubjectLine + " <<< No Previous in Subject";
}
combinedSubjectLine = combinedSubjectLine + "<span style=float:right;>"
if (nextSubjectPathString) {
combinedSubjectLine = combinedSubjectLine + dv.fileLink(nextSubjectPathString, false, "Next in Subject >>>");
}
else {
combinedSubjectLine = combinedSubjectLine + "No Next in Subject >>>";
}
// Print Combined Lines
dv.span("<br>");
dv.span(combinedSubjectLine);
To write a line with previous and next subject. This allows me to browse through related notes.
Unfortunately, this has the same issue - dv.current relates to the footer Note, not to the parent note. So, I solved one (or rather, Zodian did :)) but still not there.
Yes, you are having the same issue with dv.current.
Two ideas:
Can you access the Obsidian API from your footer? You could try to get the active file (getActiveFile()) which will mostly be also the note you are currently working on.
Dont have them as a footer in your note, but as a separate tab in the sidebar. At least for this` in bases, it will then reference the currently active note.