using "[[]]" in queries doesn't work
Closed this issue · 4 comments
I want to display a page gallery of all the pages that link to the current page (filtered by tag, but that's irrelevant).
In DataView, the simple query "LIST FROM [[]] and #my-tag" works just fine, but when I use that in page-gallery it doesn't, for some reason. If I change the query to "from: '[[MyPage]] and #my-tag'" it works, but that means I have to enter the page name manually and it will break on renames.
The same is true for "where". If I put "where: contains(myKey, [[]])" it never works, but "where: contains(myKey, [[MyPage]])" works fine.
Would be great if that could be fixed as it makes it so much easier to write reusable galleries.
The from
clause issue should be fixed in 0.7.3. I haven't found a way to get self-links working in the where
clause or other fields (sortBy
, fields
, groupBy
have this issue as well), since there doesn't seem to be a way to pass the origin page into the DataviewApi#evaluate
function right now; it seems to be using a default LinkHandler with ""
as its base path, and I can't find a good way to override/replace that without copying a bunch of internal Dataview code. I'm going to open an issue on https://github.com/blacksmithgu/obsidian-dataview to see if the evaluate
function can be updated to support different origin pages. I'll keep this issue open and link it to that one.
Opened blacksmithgu/obsidian-dataview#1930
Tentative PR: blacksmithgu/obsidian-dataview#1931
As a workaround, you can use this
in the where
, sortBy
, fields
, and groupBy
settings to refer to the current page; so this query should also work: where: contains(myKey, this.file.link)
.
Oh nice, thanks!