Question on $_SerializerTool and .replaceAll
Hi Support Team -
I have a simple question regarding $_SerializerTool and .replaceAll function.
In this format script, I successfully retrieve and display the WYSIWYG body:
#set($data = $_XPathTool.selectSingleNode($contentRoot, "calling-page/system-page/system-data-structure"))
#set($body = $data.getChild("body"))
$_SerializerTool.serialize($body, false)
I would like to use .replaceAll to replace a string inside the WYSIWYG with another string.
For example, in the text body, the string 'agf_current_aum' with 'Cdn$40 billion', with the '$' properly escaped
When I code it this way, adding the third line:
#set($data = $_XPathTool.selectSingleNode($contentRoot, "calling-page/system-page/system-data-structure"))
#set($body = $data.getChild("body"))
#set($body = $body.value.replaceAll("agf_current_aum", $AGFcurrentAUM))
$_SerializerTool.serialize($body, false)
It simply outputs the command '$_SerializerTool.serialize($body, false)'
There is obviously something wrong in the way I coded this, I'm sure you can enlighten me. :)
Thanks for your help.
Rommel
_____________________________________________________________
Rommel Lagman
Developer, I.T. Development Services
AGF Investments Inc.
Tel: 647-253-6908
Email: [email blocked]
This email message is confidential to the intended recipient and may be privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorized. Any unauthorized use, dissemination of the information, or copying of this message is prohibited. If you are not the intended addressee, kindly notify the sender by return e-mail and delete this message.
Le pr?sent courriel est strictement r?serv? ? l'usage du destinataire pr?vu. Il peut contenir des renseignements privil?gi?s et confidentiels. L'acc?s ? ce courriel par une personne autre que son destinataire est interdit. Il est aussi interdit d'utiliser, de diss?miner ou de copier ce message sans autorisation. Si vous avez re?u ce courriel par erreur, veuillez en aviser l'exp?diteur et d?truire le message.
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
1 Posted by Ryan Griffith on 16 Mar, 2015 06:13 PM
Hi Rommel,
It looks like you have the right idea; however, you will want to run the
replaceAll
after using the Serializer Tool, becausegetChild
is returning an Element as opposed to a String.When you have a moment, try something like the following and let me know how it works out:
Please let me know if you have any questions.
Thanks!
2 Posted by rommel.lagman on 16 Mar, 2015 06:42 PM
Works like a dream! Thanks Ryan!
I have to refresh myself on these basic concepts (i.e. element vs. string), I get confused with them after a while of not working with them.
We can close this discussion, thanks again.
Rommel
3 Posted by Ryan Griffith on 16 Mar, 2015 07:23 PM
Thank you for following up, Rommel. I am glad to head my suggested change did the trick.
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!
Ryan Griffith closed this discussion on 16 Mar, 2015 07:23 PM.