Velocity syntax for conditional statement with two or more conditions

voltmer1's Avatar


24 Aug, 2016 03:25 PM

I thought this would be simple, but I am trying to check for multiple conditions on an "if" statement in Velocity using the code below, it's not acknowledging the second condition.

  #set( $second_level_index_page_title = $second_level_index_page.getChild('system-data-structure').getChild('header').getChild('title').value )
                                #set( $second_level_index_page_path = $second_level_index_page.getChild('path').value )
                                #set( $courseCatalog = $second_level_index_page.getChild('name').value.contains('course-catalog') )
                                #if( $second_level_index_page_title != '' )
                                        <a class="nav-primary-opener" href="$second_level_index_page_path">${_EscapeTool.xml($second_level_index_page_title)}
                                            <span class="nav-primary-opener-icon">
                                                <span class="icon-plus">
                                                    <span class="hide-for-screen-reader">Open</span>
                                                <span class="icon-minus">
                                                    <span class="hide-for-screen-reader">Close</span>
                                        <div class="nav-primary-block">
                                            <ul class="nav-primary-third-level">
                                                #if( ($second_level_index_page_title != '') && (!$courseCatalog) )
                                                        <a href="$second_level_index_page_path">More about ${_EscapeTool.xml($second_level_index_page_title)}</a>
Is my variable $courseCatalog correct calling the method of contains('course-catalog') from "value"?
  1. 1 Posted by voltmer1 on 24 Aug, 2016 04:18 PM

    voltmer1's Avatar

    Well, I still need help after all. My question still stands. Thanks!

  2. 2 Posted by Ryan Griffith on 25 Aug, 2016 12:25 PM

    Ryan Griffith's Avatar


    Your conditional statement appears to be correct, so it's most likely something with either variable. Try outputting each to see what their value is.

    Also, I wanted to note that you already have that entire markup surrounded with a check to see if the title is not empty, so you can technically drop that portion of the conditional.

    Please let me know if you have any questions.


  3. 3 Posted by voltmer1 on 25 Aug, 2016 12:28 PM

    voltmer1's Avatar

    Thanks Ryan! That was it. The variable wasn't outputting the value I was expecting. You can close this ticket. Thanks again!

  4. 4 Posted by Ryan Griffith on 25 Aug, 2016 12:50 PM

    Ryan Griffith's Avatar

    Not a problem at all. I am glad to hear I was able to help point you in the right direction.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  5. Ryan Griffith closed this discussion on 25 Aug, 2016 12:50 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM