Hi! I’m trying to create a template where it will automatically create a table showing all notes tagged with the title, listed in the order created showing the date the file was created, or last modified.
Things I have tried
This is what I have tried but it doesn’t seem to work:
table file.ctime as "Created"
WHERE type = "note" and tag = "<% tp.file.title %>"
sort file.ctime DESC
It’ll always fail when viewed as a template, but does it still fail after creating a file based on your template?
Another tip: when using a dataview query, like yours, you could use this to refer to the current file. In other words a clause like file.name = this.file.name would limit itself to file of that name.
Finally, doing tag = file.name could work in your case, as long as that is the only tag for the other files. A safer version would be to do something like: econtains(file.etags, "#" + file.name)
Bonus tip, putting a query within a daily note, could be a bad idea related to what happens if/when you want to change that query? So I’d suggest looking into dv.view(), which would give you a more flexible way of doing stuff like this, as then you could change the script and have it apply to your daily notes the next time you view them.
Final bonus tip, adding four backticks around your markdown and/or queries will make them appear nicer in a forum post.