Have current-page trigger only when template is applied

I have the following code to get scheduled or non-scheduled tasks for the daily page i’m at:

#+BEGIN_QUERY
{  :query [:find (pull ?b [*])
    :in $ ?current-page
    :where
[?p :block/name ?current-page]
(or
[?b :block/refs ?p]
[?b :block/scheduled ?p] ;; ahahaha
)
(task ?b #{"TODO"})
]
:inputs [:current-page]
:group-by-page? false
:breadcrumb-show? false
}
#+END_QUERY

It works well if i use the specific page, but if i go to the journal page where all the pages are listed, i lose the data. Is there a way to make current-page applied only when the template is applied?

I tried using the <% current-page %> in the code but that is replaced with current-page.

Do i have to use a page property to set the current-page static and then replace the current-page on the code with page property?

1 Like

Found another post using query-page as the inputs which seems to do the job i was looking for.

# #Tarefas:
#+BEGIN_QUERY
{  :query [:find (pull ?b [*])
    :in $ ?current
    :where
[?p :block/name ?current]

(or
[?b :block/refs ?p]
[?b :block/scheduled ?p] 
)

(task ?b #{"TODO"})
]
:inputs [:query-page]
:group-by-page? false
:breadcrumb-show? false
}
#+END_QUERY
2 Likes

For completeness:
current-page uses the page the main window is on. query-page uses the page the query is on.
So have the query in the side bar or as embed would change the output of you use current-page, but not when using query-page.

2 Likes