Dataview Listing Items in Folders where folder structure is a YAML tag in the note

I have a Tag in the note and I want to be able to do a


My Tag: /folder/folder1/folder2

LIST FROM #My Tag

Not sure how to code the FROM section or if it is even possible?

This works, but probably not what you want if trying to use tags as designed (My Tag is not valid YAML for regular tags, AFAIK):

---
MyTag: "/folder/folder1/folder2"
---
```dataview
LIST
Where MyTag = "/folder/folder1/folder2"
LIMIT
5
```

Alternatively:

---
Tag: folder/folder1/folder2
---
```dataview
LIST
FROM #folder/folder1/folder2
LIMIT
5
```

Yes I was just using the space for readability but the value MyTag contains the folder structure.

What I was wondering is if MyTag had a value of /folder/folder1/folder2

I want to list all notes in the particular structure location.

if I do a FROM “folder/folder1/folder2” everything works.

But I am creating this note using templater and the folder structure will be different. The MyTag is being set using Javascript in the templater template.

so I wanted to use the tag in the note for the directory structure of the FROM clause.

Are you expecting the folders to be identical to MyTag, or also everything in sub folders?

The alternative to using FROM <MyTag> (or variants thereof which doesn’t expand the variable, as you most likely have discovered) are:

WHERE file.folder = MyTag
WHERE startswith(file.folder, MyTag)

The first variant checks for files within the exact folder as your tag, and the second variant covers all files in that folder and sub folders. Play around a little with whether you need a trailing / or not. I think it should be fine not having it.

If you’re not using the MyTag for any queries as such, or just in one given query inserted from Templater, you might also consider actually setting that folder directly into your query within the template. But that would require us to see your template code, to aid in how and where to insert that.

Yeah I could do that in the templater side of things if I could figure out how to put the " " around this code.

<% tp.file.folder(true) %>/Meetings

in the From( ) of the dataview query.

Still a little sparse on the information, but maybe you could use\" to get the quotes?

LIST

FROM (<% tp.file.folder(true) %>/Meetings)

This produces the directory structure like /Customers/Deals/Deal 1/Meetings but I need that wrapped in quotes for dataview to work.

The Wrapping it in Quotes is what is causing me angst

I feel like I’m repeating myself, so this is the last time. If you don’t show how to you generate that query from within your template, I’m not able to provide any help either. We still don’t know enough about how you’re surrounding code looks like.

So how does the entire template (or at least the full section producing this dataview query) look like?

And is this a core template, Quick Add template or Templater template?

Just another guess if this is at the base level of your template, then why not just do:

```dataviewjs
LIST
FROM "<% tp.file.folder(true)" %>/Meetings"
```
```dataview
LIST
FROM (<% tp.file.folder(true) %>/Meetings)

``` .
Sorry I missed the code snippet button as it did not show and this is a templater template I am just creating a note from template.

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