I seem to always have issues with this and can never remember how to resolve it. I have spent the past two days reviewing the forum trying to find a solution and have not been able to find one that works. I am sure I have missed something very simple, because this is a fundamental thing, but the answer escapes me.
What I would like to do is have either a button or a link on a nodejs page that when clicked takes a user to an edit page but it could also be something that links to a details page, etc.
I have my route set up as /company/edit-national/:id
I have two buttons set up on a page. Both work the same way, but come about it differently.
The first button is an anchor button with the following attributes.
The second is a regular button with the following attributes.
$_PARAM.id doesn’t exist in the Server Action. You’re calling the server action “/edit”, where’s the param there? You didn’t call the server action like /edit/123
To access values of query parameters in Server Actions from Server Connects is via $_GET variables. If you set up a GET variable $_GET.id and replace the query condition with the $_GET.id variable, the query will filter the data based on the pc_id.
You would change “id” to whatever you named your variable in the query params.
That made it work for me.
I am a little confused why the query params was not selectable through the picker, but I have made a note of it so will remember in the future and not have this issue again.
Glad that it is working now. I think the confusion may be arising from the term dmx-param in Server Connect, required to access the $_GET variables on the front-end.
Was your App ID (in the Content page) the same as the Layout page? If not parameters, cookies, and Data Store schema items will not be accessible in the picker…
Thanks @scott. I have route parameters on server connects working fine and they send the $_GET variable to the server side and I can use them. My issue was I was trying to make the server connect dynamic to where I didn’t have to put a value in an input parameter on the server connect because where I was trying to use the server connect, there’s nowhere to put the parameter. Perhaps I’m still confused on the difference between $_PARAM and $_GET. I know how to use $_GET and $_POST I don’t understand the use case for $_PARAM. I thought it was a way to grab a param from the url on the server side without having to send it via server connect input params.
For instance, I’m trying to get the title, keywords and other meta data from values stored in the database based on the current page. There’s no way to send an id or page identifier to the server side that I can see.
@TwitchBlade, what I did was watch @Hyperbytes video here. Videos 26-29 cover using the globals server action to do the SEO tags. Then for page specific data, use the $_GET variable as outlined above.