Is it possible to create a command/template to dynamically change a website URL link?

Is it possible to create a command/template that I can insert into a note that would read the parameter of a note and update the URL of a link?

ex: Let’s say I want to search youtube for whatever I type in the search_parameter below:

search_parameter: test (user can type this in or even better if it can dynamically link to another property in the same note)

If I type in “test” on youtube, the URL becomes: “

It seems to me it should be possible if the command can copy the value of search_parameter and place it right after the search_query= in the actual youtube link.

It’s possible with dataview. But depends if you want to use the plugin; if you use reading view instead of live preview; if you want an instantaneous update of the link; etc.

Appreciate the quick response. If you have any spare time, would you be able to help me with this? This would be used mostly during live preview mode.

Basically, there is a website with a glossary of things I want to use for my games, and the search URL follows a consistent pattern.

I was hoping to have a way to be able to type a specific value into the search_parameter below and this would either create the link in obsidian and/or open the updated link based on what I type in the search_parameter.

I’m not great at writing code, but I can certainly modify it if I have a starting point.

Thanks again!

ok. Let’s say you create this inline field

searchTerm:: obsidian

or a frontmatter field

searchTerm: obsidian

Then you can explore two types of inline queries: a regular dql query or a dvjs (dataviewjs) query.
In the same note where you write the field searchTerm (choose the key you want), write these two inline queries:

### dql query
`=elink("" + this.searchTerm)`

### dvjs query
`$=dv.func.elink("" + dv.current().searchterm)`

Why I write both queries? Because the “refresh” issue. Dql query doesn’t “auto-refresh” if you change the value in searchTerm… you need to jump to another note and return to take effect. Dvjs query “auto-refresh” if you change the value. But all this in reading mode. In Live preview (LP) I think the dvjs inline query doesn’t “auto-refresh”.

To work in LP I guess you need to use a dvjs query but not an inline one. Something like:

dv.span(dv.func.elink("" + dv.current().searchterm))

But you need to try… :slight_smile:

1 Like

Amazing! The dvjs query worked like a charm. Really appreciate you taking the time to respond back to my query.

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