Oddity

steelej's Avatar

steelej

Sep 10, 2013 @ 07:57 PM

As I've been neck-deep in Velocity all day, this might be just another effect of script-blindness. I have two fields in my system-data-structure on this page, title and heading. For some reason, I can escape the ampersand character in the heading field, but it doesn't work in the title field. Am I really going blind here?

  1. 1 Posted by Ryan Griffith on Sep 12, 2013 @ 03:49 PM

    Ryan Griffith's Avatar

    Hi Jim,

    Were you able to get this working? I was able to successfully escape the two elements in my local Cascade Server 7.6 instance.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by steelej on Sep 18, 2013 @ 04:15 PM

    steelej's Avatar

    Ryan,
    Back at it. I'm on 7.6. This isn't working.
    Here's what I've noted:

    If I have the xml escape in the script for the header and use &, it doesn't render and in the XML view of the page the & has been changed to the ASCII: &

    If I enter & it escapes the character and displays &

    As the same escape clause is used twice on the page and only works in the second instance.

    I'm befuddled.
    Jim

  3. 3 Posted by Ryan Griffith on Sep 19, 2013 @ 06:49 PM

    Ryan Griffith's Avatar

    Hi Jim,

    If I have the xml escape in the script for the header and use &, it doesn't render and in the XML view of the page the & has been changed to the ASCII: &

    This is correct, Cascade Server will encode the ampersand when generating the structured data to ensure the content is valid XML.

    If I enter & it escapes the character and displays &

    This would be expected because the ampersand will be encoded, leaving you with &, which is valid XML.

    I was able to get things working using the following setup:

    Data Definition

    
    <system-data-structure>
      <text identifier="title"/>
      <group identifier="subsection" multiple="true">
        <text identifier="heading"/>
        <text wysiwyg="true" identifier="content"/>
      </group>
    </system-data-structure>
    

    Format

    #set ($dd = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/system-data-structure"))
    
    #set ($header = ${_EscapeTool.xml($dd.getChild('title').value)})
    #set ($subs = $_XPathTool.selectNodes($dd, "subsection"))
    
    <h2>${header}</h2>
    
    #foreach ($sub in $subs)
        #set ($heading = ${_EscapeTool.xml($sub.getChild('heading').value)})
        #set ( $content = $sub.getChild("content"))
        
        #if ($heading.trim() != "")
            <h3>${heading}</h3>
        #end
        
        <p>$_SerializerTool.serialize($content, true)</p>
    #end
    

    Values Entered on Page

    Title: Conferences & Registration
    Heading: test of &

    Resulting HTML

    <h2>Conferences &amp; Registration</h2>
    
        
                <h3>test of &amp;</h3>
            
        <p>When coordinating registration for an event, at least two weeks before the conference deadline for registration, organizations should prepare a list of all participants and submit an OrgSync request before meeting with their Campus Life advisor. Organizations must provide their Campus Life advisor with all necessary information about participants, which may include copies of driver&#8217;s licenses, birthdates, and/or W numbers.</p>
    
  4. 4 Posted by steelej on Sep 19, 2013 @ 07:35 PM

    steelej's Avatar

    Ryan,
    As is usual, this was my error. I was in the middle of writing an explanation that the escape tool was working in both fields as evidenced in the XML output, but kicked an error when I tried to view it in HTML. Then I reread the error. It appears I set this page up to use the data-defined title value in the page title meta-tag which does not react well to an ampersand. That was what was crashing my HTML view. I just used the replaceAll() method for the page title format to replace the & with "and." Working now. I'll read my error messages more attentively from now on.

    Thanks
    Jim

  5. steelej closed this discussion on Sep 19, 2013 @ 07:36 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