Adding URL parameters to query.

How do you add the url query parameters to the URL path? It’s not the same as with path parameters.
Is it possible to add dynamic values to these url query parameters? How do you use values from a query in these url parameters? I want to use this as a filter (override variables in query) for a query.

Hi @iridescent_platypus! You should be able to find URL Parameters panel on the right panel under Page Data, as documented here: https://docs.plasmic.app/learn/dynamic-pages/#query-parameters You can use page query parameters the same way you use page path parameters – they are available under $ctx.query (while page path parameters are available under $ctx.params)

I think Jan is trying not to read query parameters, but to add parameters to the other query parameters.

@intuitive_wildfowl What about, instead of adding to the query parameters, combining query parameters and whatever other parameters you get elsewhere into a state variable and use the data there for further filtering?

Hi @tiago and @exhaustive_panther ! I want to use the sorting and filtering from my graphql query. I want to sort a list of events on ‘genre’. The values of ‘genre’ should be a dropdown on a page. These values should also be the value of the url query parameter ‘genre’.

@tiago I post this under ‘Issues’, but its more like ‘how to’ :blush:.

Hi @iridescent_platypus! In the screenshot you have the genre query parameter. Add a preview value to it, such as “jazz”. Then, in the GraphQL query, you can use $ctx.query.genre (which will have “jazz” as a value) to filter. If you navigate to /list-5?genre=baroque the query should work accordingly. So the last part that is missing is making the Select navigate to a URL based in its value. To do so, you can use a “On change” interaction in the Select component with a “Page navigation” action. Let me know if that works for you!

Alright @tiago, I will try this out. Another related question: if there is a query parameter, the url of the page without the query parameter doesn’t give content. Can you make the start url as alias, for instance: ‘/event’ as an alias for ‘/event?p=0’ ?

Do you mean you want to redirect users that hit /event to /event?p=0? Or do you just want to have “0” as the value for $ctx.query.p in case no value is specified?

The last suggestion sounds good.

In that case you can just use $ctx.query.p ?? "0" when you want to use that value.

@tiago It works! Thanks for the advice!