It did not work. Iām not sure it can handle ANDs in the condition. I think I may need to build more specific Server Actions that will return a boolean.
Well yes actually you should declare everything in the ServerAction and also at AppConnect. I created something similar some time ago. If I remember where I used it I will send you a sample.
This is a problem I'm encountering though and I need to have a condition that checks which page the Action is on. PHP_SELF is returning the Server Action file name, not the page file name.
You can use ā&&ā etc. in ternary operators in Wappler. Eg you can do some simple tests such as: {{2>1 && 4>3 ?'result1':'result2'}}
or {{(2>1 && 4>10) || 4>3 ?'result1':'result2'}}
I asked about this recently. I think the ternary operator is the only option but there wasnāt an official reply.
I have tried PHP_SELF, REQUEST_URI, and SCRIPT_NAME. All of them return slightly different references to the Server Action file, not the page itās running on.
This is what is returned when using a set value in Server Action, but I would hope this would show the page itās on, not the Server action file name. /dmxConnect/api/Security/userDetails.php?
Here is my code in my header.php server include to display the page/file name <p dmx-text="userDetails.data.currentPage"></p>
Hereās is what shows on my home page and all of pages that use the header include.
Taking this a step further. If I add the Server variables directly to the header include file then these <p dmx-text="userDetails.data.currentPage"></p> <p><?php echo $_SERVER['PHP_SELF'] ?></p> <p><?php echo $_SERVER['SCRIPT_NAME'] ?></p> <p><?php echo $_SERVER['REQUEST_URI'] ?></p>
Produce these. This was taken from the āprojects.phpā page with route āprojectsā /dmxConnect/api/Security/userDetails.php? /projects.php /projects.php /projects
So REQUEST_URI is what I want to use, but using it in the Server Action is pointless.
To close the loop. I found a way to accomplish my need. I had to add the $_Server Variable directly to the page, instead of in the Server Connect Action. Additionally, the php code needs to be in between single quotes.
The below code checks the value of the āConfirmā field on the current userās record. If it is 0 and the current page is not the āconfirmā page, then we redirect to the confirm page.