Rain (IF Statement) Conditional is not firing on page that I am specifying

ryanbrownmediaryanbrownmedia Member Posts: 1

Hello and thanks for taking the time to read this.


My client needs a hero to show up on 2 specific pages. In my custom.rain file I have a conditional firing for each of the pages.. when the the current page is one of the desired pages in the if statement, my div appears. It is essentially a Hero image on top of the page. This is working on 1 of the pages, but not the other. It is also not an issue of my IF statement, as it was working on 2/2 test pages. It seems the TITLE of the page that I am using in the conditional is just not the same title as the page that Lightspeed has for that page?

Here is my simplified code, just showing the parent DIV but not the child elements they contain for simplicity sake.



// custom.rain

 {% if page.title == 'All Products' %}

<div class="all-products-hero">   </div>

  {% elseif page.title == 'Equipment Rentals' %}

<div class="all-rentals-hero"></div>

{% else %}

{% endif %}



If I enter the title "Rentals" OR full title in my conditional "Equipment Rentals", neither works.

It is like the page is actually called something different because if I just put the div on the page without the conditional, it will appear on every page, including this rentals page. But when I'm trying to have it JUST show on the rentals page, my conditional doesn't show it.


I had to put a div on every page, display none it, and then use JS to query the window object's URL to change the CSS of the div to show on only this page.... not ideal, and it takes a second before the image pops up. However, on the All Products page everything is working as it should with the conditional above.


https://www.azmediquip.com/rentals/

Thank you so much for your time!

1 comment

  • koen_schenkkoen_schenk Member Posts: 4

    Hello it seems like the title you are using in your if statement for the rentals page is wrong it should be: Home Medical Equipment For Rent

    You can see this data more clearly by entering tb/show in the search bar of your website. Now you should see something like this if you click on Template object > page:

    And that is the title you should be using in your if statements. Hope this helps.

Sign In or Register to comment.