case insensitive xpath select

Justin "JET" Turner's Avatar

Justin "JET" Turner

Apr 26, 2013 @ 02:14 PM

Hello,

We are currently using a custom metadata field on images and pages to link the two together for our faculty bios. The field contains the users email address.

Right now, this works as long as they are both the same case.

For instance First.Last @ ung.edu won't match first.last @ ung.edu

Below is a few of the key lines from the format.

1. #set($page = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page"))
2. #set($email = $_XPathTool.selectSingleNode($page, "dynamic-metadata[name='email']").getChild("value"))
3. #set($query = "system-file[dynamic-metadata[name='email' and value='" + $email.value + "']]")
4. #set($images = $_XPathTool.selectNodes($control.getChild("images").getChild("content").getChild("system-index-block"),$query))
  1. 1 Posted by Ryan Griffith on Apr 26, 2013 @ 03:09 PM

    Ryan Griffith's Avatar

    Hi Justin,

    I believe your best bet here would be to surround value with a translate() statement to convert it to lowercase, then also convert $email.value to lowercase, so you can match the two up. For example:

    #set($query = "system-file[dynamic-metadata[name='email' and translate(value,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='" + $email.value.toLowerCase() + "']]")
    

    Please let me know if you have any questions.

    Thanks

  2. 2 Posted by Justin "JE... on Apr 26, 2013 @ 03:18 PM

    Justin "JET" Turner's Avatar

    Thanks, that did it!

  3. Justin "JET" Turner closed this discussion on Apr 26, 2013 @ 03:18 PM.

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

Keyboard shortcuts

Generic

? 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