Locator Tool and Serializer Tool

Ashley Williams's Avatar

Ashley Williams

27 Mar, 2014 08:41 PM

Hi,

First let me say that we love the locator tool! It's helping us cut down our rendering time. :)

That said, I was wondering if it's possible to use the Serializer Tool on WYSIWYG content pulled with the Locator Tool? I tried this:

#set ( $physical_address = $page.getStructuredDataNode("department-information/physical-address").textValue)
## Using the escape tool sort of works...
$_EscapeTool.xml($physical_address)
## The serializer tool does not work
$_SerializerTool.serialize(physical_address, true)

The above outputs:

<p>Words words words<br/>Even more words</p> 
$_SerializerTool.serialize(physical_address, true)

The Escape tool shows the mark up from the WYSIWYG (which I expected) in the output, and the way that I'm trying to use the serializer tool doesn't do anything at all. Any help is appreciated. Thanks!

  1. 1 Posted by Ryan Griffith on 28 Mar, 2014 01:18 PM

    Ryan Griffith's Avatar

    Hi Ashley,

    It looks like you are missing the dollar sign before the physical_address variable. When you have a moment, try the following and let me know how it works out:

    $_SerializerTool.serialize($physical_address, true)
    

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by Ashley Williams on 31 Mar, 2014 12:37 PM

    Ashley Williams's Avatar

    After adding the $ to physical address, I still have the same problem (though I should have noticed that before asking, thanks for catching that). Now the output is:

    $_SerializerTool.serialize($physical_address, true)
    
  3. 3 Posted by Ryan Griffith on 31 Mar, 2014 03:14 PM

    Ryan Griffith's Avatar

    Thank you for following up, Ashley.

    Looking over your code snippet again, I noticed you are setting the $physical_address variable to the node's textValue property. I suspect the issue is occurring because the Serializer Tool expects a JDOM Element to serialize, but you are passing in a String.

    When you have a moment, try the following and let me know how it works out:

    #set ( $physical_address = $page.getStructuredDataNode("department-information/physical-address"))
    $_SerializerTool.serialize($physical_address, true)
    

    Please let me know if you have any questions.

    Thanks!

  4. 4 Posted by Ashley Williams on 31 Mar, 2014 03:37 PM

    Ashley Williams's Avatar

    Removing ".textValue" doesn't seem to work either. Here's my code in its entirety (though I did take out the EscapeTool part since that no longer works after I removed .textValue):

    ## Get folders
    #set ( $folders = $_XPathTool.selectNodes($contentRoot, "//system-folder[descendant::system-page[@current]]") )
    #set ( $blank = "" )
    
    $_SortTool.addSortCriterion("count", "", "text", "descending", "upper-first")
    $_SortTool.sort($folders)
    
    #foreach ( $folder in $folders )
        
        ## Get _info file
        #set ( $infoFile =  $_XPathTool.selectSingleNode($folder, "system-page[name='_info']") )
        #set ( $page = $_.locatePage($infoFile.getChild("path").value, $infoFile.getChild("site").value) )
        
        ## Physical address
        #set ( $physical_address = $page.getStructuredDataNode("department-information/physical-address"))
        
     #end
     
     #if ( $infoFile )
        <p class="title">Contact</p>
        
        ## Physical Address
        #if (!$_PropertyTool.isNull($physical_address))
            $_SerializerTool.serialize($physical_address, true)
        #else
            ${blank}
        #end
    
    #else
    #end
    
  5. 5 Posted by Ryan Griffith on 31 Mar, 2014 03:59 PM

    Ryan Griffith's Avatar

    Hi Ashley,

    Thank you for providing the entire Format.

    It looks like you are displaying the content outside of the #foreach loop. Perhaps try moving that inside of the loop to see if that changes the output.

    Also, can you confirm the #if statement that outputs the content is returning true?

    I did take out the EscapeTool part since that no longer works after I removed .textValue

    Correct, the Escape Tool expects a String, so passing in the JDOM Element will cause that to break. If you do need to escape the content, you would want to pass the serialized content into the Escape Tool. Something like the following:

    #set ( $physical_address = $_SerializerTool.serialize($physical_address, true) )
    $_EscapeTool.xml($physical_address)
    

    Please let me know if you have any questions.

    Thanks!

  6. 6 Posted by Ashley Williams on 31 Mar, 2014 04:11 PM

    Ashley Williams's Avatar

    This is what made it work. I have the below set up in the #foreach loop:

    #set ( $physical_address = $page.getStructuredDataNode("department-information/physical-address").textValue)
    #set ( $physical_address = $_SerializerTool.serialize($physical_address, true) )
    

    Then I used ${physical_address} to display it in the #if statement. Thank you for your help!

  7. 7 Posted by Ryan Griffith on 31 Mar, 2014 04:15 PM

    Ryan Griffith's Avatar

    Ah, my apologies, Ashley. I didn't take notice of the getStructuredDataNode part, so you're right in that textValue should give you the content to serialize.

    I am glad to hear you were about to get things working. I'll go ahead and close this discussion, but please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  8. Ryan Griffith closed this discussion on 31 Mar, 2014 04:15 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

 

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