Can I do conditional rendering based on a query string ($Param) value?

  • 2
  • Question
  • Updated 4 years ago
  • Answered
Is it possible to do conditional rendering using something other than a model - in particular using a query string via $Param?

What I'm really trying to do is to pass a value into a shared Page Include to slightly alter it's behavior (it's a commonly used and somewhat complex page used in a popup window via page include, and having slight variations based on the query string would allow me to disable or change some simple functionality of the page based on which buttons opens it).

So another answer may be to find a snippet that looks at the query string and adjusts the page content ... which in this case is to hide some fields. As discussed on another forum topic (https://community.skuidify.com/skuid/...) the complexity is then in stopping the field validators from requiring field values when the fields are hidden. If I can use a query string in conditional rendering, the problem goes away. But if not, I still need a way to do conditional rendering or eliminate field validation from within a snippet.

Thanks ... and in case you didn't know, we became an official customer today!

- Chris
Photo of Chris

Chris

  • 1,632 Points 1k badge 2x thumb

Posted 5 years ago

  • 2
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Hi Chris,

What parts of the content of your Page Include do you want to conditionally render based on the value in the URL Parameter? Sounds like Fields in a Field Editor, but I just wanted to check. Also, what sort of different values are you passing in?

I think that your idea about basing the rendering on something other than Model data definitely makes sense, we've been thinking about this for a future release.

However, in the meantime, you could achieve this through a "hack" approach that is fully supported and should work fine: base your Conditional Rendering on a "dummy" Model with a dummy row with one field that gets fed the value of the $Param. So in your included Page(s), add a Model on some object that all users will always have access to, and then pull in one text field on that object that your users should have edit permissions on. Check the "Create a Default Row" property for that Model (in the Model's "Advanced" properties), and uncheck the "Load model data..." property. Then add one Condition to the Model, on the dummy text field you pulled in, and have its Value be set to pull from the URL Parameter you send in. Then you should be able to use this Model to do Conditional Rendering.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Chris... Welcome aboard.  We are really glad to have you as a customer.  We'd love for you to give us some feedback on our app exchange listing.  What do you love?  What could we do better?   We want to hear the voices of our customer.  Here is the URL for that listing.

Zach... That "hack" approach is so devious it is probably illegal in 30 states.  Well done...  
Photo of Chris

Chris

  • 1,632 Points 1k badge 2x thumb
That is quite a hack ... but it does work!  Thanks!
Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb
Can someone post more details or screenshots on the model & page element rendering options I have to use to make this work? I'm passing a URL param into my page that populates a model filter, and I want to show text at the top of the page that says what the page is filtering on. I also want to NOT render that text when there is nothing passed into the page (i.e., there is no active filter). I can't seem to make this work, though. I'm probably just setting one of the many options incorrectly, but I can't figure out which.