BUG? Can't add "IF" string comparison to System Default Page

I’m trying to customize the System Page > Default Page, but keep getting the “Liquid Error: Object reference not set to an instance of an object.” error.

In trying to debug, here’s what I’ve uncovered. If I compare strings it fails. If I compare integers it works:

This works:
{% if 1 ==1 %}
true
{% else %}
false
{% endif %}

And this fails:
{% if “1” == “1” %}
true
{% else %}
false
{% endif %}

I’m trying to implement something like the following to redirect a user submitted custom module after using the input form:
{% if this.PageType == “AddNewModuleItemSuccess” %}
{% if this.FormSubmissionData.ModuleItem.ParentId == “2437” %}
use js to redirect to item url
{% endif %}
{% else %}
< div>
{{this.Message}}
< /div>
{% endif %}

Have you tried the ParentId as an integer? ie:

{% if this.FormSubmissionData.ModuleItem.ParentId == 2437 %}

I just did a test with your code and it worked fine for me (both ways, comparing the ParentID as a number or a string).

And tested with Liquid 2.0 on and off - both ways worked.

So must be something else going on here I think…

Usually that Liquid error relates to a component module with something wrong in it, not from conditional statements (in my experience).

Yes that works.

But …

  1. The parent id is off by 5, right?
  2. I really will need to the string comparisons for more complex logic

Have you tested any string? {% if this.PageType == “AddNewModuleItemSuccess” %}

  1. Yes, id is off by 5. You can double check you have it right by outputting the object, ie: ({{this.FormSubmissionData.ModuleItem.ParentId}})

Yes. Tested your exact code and both conditionals worked.

Check your double quotes in the first if statement. I think you have ‘smart quotes’ there instead of normal quotes.

I get the same error when I change these to smart quotes, eg:

smart quotes:

“AddNewModuleItemSuccess”

normal quotes:

"AddNewModuleItemSuccess"

Single quotes worked! Thanks!

Also … another roadblock. My redirect is failing:

This tag produces:
https://bonaparte.treepl.co/member-event-responses/z_lynd-shannon-and-lynd-kirk-dual-mardi-gras-day-party-20200701

and I get a Page Not Found.

The url that works is:
https://bonaparte.treepl.co/member-event-responses/z_Lynd,%20Shannon%20and%20Lynd,%20Kirk%20-%20Dual%20-%20Mardi%20Gras%20Day%20Party%20-%2020200701

Do I need to encode or decode it?

Yeah, looks like you need to encode it.

https://docs.treepl.co/documentation_group/liquid-filters/standard-filters#secStringUrl_encode

“| Url_encode” didn’t work. (“Url_decode” didn’t either).
How would it know which dashes were real and which aren’t?

I was able cobble it together with hard-coding the module path and the Url slug.

Don’t you think that this {{this.FormSubmissionData.ModuleItem.Url}} might be a bug. I mean, shouldn’t it produce a working Url?

Adam - Thanks so much for taking the time to help! I so appreciate it :slight_smile: :star_struck:

No problem @shannonlynd. Happy to help.

Yes, looks like the bug is to do with user submitted items not following the same URL convention as what is generated when adding items in the admin.
It keeps the spaces in the URL and so we need the %20 encoding for a space.
image
But the Liquid output in the form submission shows it with dashes.

Ideally, the user-submission process should convert spaces to dashes for consistency.

@vlad.z looks like this is a bug.

Added to the known bugs section of the team backlog