<%if (serverdata) { %>
<p>Do not render this paragraph</p>
<% }
The condition(as a good condition) won’t evaluate always to the same value.
Imagine I have a set of cards rendered via an AC repeating row component.
Each card will have different html depending on server data. I don’t want to show/hide in the DOM. I want to avoid altogether that it is inserted in the DOM.
This is not going to be an easy one right @patrick?
I’ve been checking the core files and I can’t possibly think of a way to accomplish this with the current set of features available. I miss additional horsepower when working with templates.
Yes, ejs conditions do work. But the data available will be only of two types. Static data I add to routes.json or the output of a SC assigned to the route. As expected of course.
However the SC uses parameters to filter so if I load the page: “Undefined binding(s) detected for keys…”
It seems that current functionality is limited or geared towards meta tags and getting data that doesn’t depend on query parameters.
Query parameters should be supported, how do you use them?
Please note that in NodeJS there is a difference between query parameters and path parameters. Lets say you have a route path like /page/:id, you get the id with $_PARAM.id. Query parameters like $_GET.id will only get parameters after the ?, like /page?id=1.
I know it’s been a long time ago and this thread is NodeJS related but searching didn’t bring something that can help me on it (or I haven’t found anything yet)…
Is there a workaround in php mode for accessing wappler SC & AC actions and control conditional rendering elements?
For example:
<?php if ( ***serverconnect_Action.identity == 1*** ) { ?>
There are template functions coming to PHP that will allow you to access data from a serverconnect action that can be included on the page. Can't say how long the implementation will take but I already did some preparations in the PHP code for it.
Here a sample of the current experimental implementation, this can change in the future.
<!-- tell serverconnect we are in a template -->
<?php define('TEMPLATE', true); ?>
<!-- simply require the serverconnect action, it will run directly -->
<?php require('dmxConnect/api/myaction.php'); ?>
<!-- inserting data from a serverconnect expression -->
<?=_parse('expression')?>
<!-- using expression in a if statement -->
<?php if (_parse('expression') == 1) { ?>
Great!
Manual PHP layout using routing is fast, but not as fast and intuitive as NodeJS.
It's always very difficult to start all over again when routing doesn't work anymore after many changes to the page.