Is it possible to use a server connect value as a filename for a partial? Basically I’m trying to create a dashboard with configurable components being displayed with different partials based on the dashboard component required.
You’re trying to access this variable at server-side rendering phase, but the variable is only created way after the page has been rendered in the browser. You can’t ask the server to include a partial from a variable it doesn’t exist at the time
You need to run such server connect at server-side instead of asking the browser to run such
Thanks for the response and suggested article. I may not be fully understanding how the server side rendering piece would work, at least based on the examples as I won’t know the filename to load until run-time.
Basically let’s say I have 10 partials/snippets/content pages, whatever you want to call them, containing the code of each component as a catalog of components available. A user can select 4-6 of them to load and display on their dashboard based on their preferences.
I’m not entirely sure if this is possible in Wappler but seems like it should be doable somehow.
I don’t fully understand the use-case, but I think what you want is possible
After you know the filename, is it possible you can use the Browser component to redirect the user to the current page plus a GET argument containing such value? Then, you’re able to do a partial include by looking at the $_GET variable
Note that, after you get this working, you will eventually need to use server-side rendering to filter the $_GET variable, as you may want to restrict the filenames the users may be allowed to access, otherwise this is a security issue
perhaps rather than try to specify the partial name as a variable you could place them in a conditional regions to they are only rendered under the appropriate circumstances. Think that should work (never tried)
Thanks! That’s a potential option but it would still load, not display, all of the partials during rendering. I’ll play around with that for a while to see how big of an impact it may have.
Still hoping for a cleaner solution, if one exists.
If it is in a conditional region it should not load, that is the difference between using a conditional region and using to show/hide where it would be loaded then shown/hidden accordingly
Hmm…I tried both with show/hide and a conditional region and they act the same as far as I can tell. Both brought in the partial into the DOM even though it was never displayed.
EDIT : I was looking at the source, not DOM. So in fact the conditional might just work. Thanks!
JonL - I’m not sure this is exactly what I’m looking for unless I’m missing something here. I’m not merely trying to render a few attributes from server side but a set of full partials like a card with a chart in each. Referencing back to my poorly thrown together image, a user could have selected many partials in any order for their dashboard. Perhaps what you provided is what I need and I’m just not connecting the dots properly in my head.