js menu and string replacement
I have a js menu for navigation using velocity format for output. The menu items are pulled from the title field of a data definition. I need to replace the apostrophe in the tile. I've tried this:
#set ($itemTitle = $itemTitle.replaceAll("'","\'"))
It doesn't seem to work. The still breaks if there is an apostrophe in the page title.
Showing the most recent page of comments. View the first page
Comments are currently closed for this discussion. You can start a new one.
Support Staff 32 Posted by Ryan Griffith on 06 Jul, 2012 12:48 PM
Charla,
I came across the
url()method for the EscapeTool, perhaps this may help. Let's try the following.Replace:
With:
33 Posted by Charla on 10 Jul, 2012 06:23 PM
This is the error it came back with:
Jul 10, 2012 1:13 PMAn error occurred: Error on line 75: The entity name
must immediately follow the '&' in the entity reference.
You may choose to retry the operation <>. If the problem persists, please
contact a system administrator.
The error has been logged to the system console.
Home https://cmsprod.lamar.edu/home.act
With the macro looking like:
On 7/6/12 7:48 AM, "Ryan Griffith"
[email blocked] wrote:
CONFIDENTIALITY: Any information contained in this e-mail
(including attachments) is the property of The State of Texas and unauthorized disclosure or use is prohibited. Sending, receiving or
forwarding of confidential, proprietary and privileged information is
prohibited under Lamar Policy. If you received this e-mail in error,
please notify the sender and delete this e-mail from your system.
Support Staff 34 Posted by Ryan Griffith on 10 Jul, 2012 07:11 PM
Hi Charla, would you be able to provide me with a copy of the XML, or index block, that this Format is applied to? I'll see if I can get something set up in my local instance to I can test some more.
Thanks!
35 Posted by Charla on 10 Jul, 2012 07:29 PM
It doesn't apply to an index block, it applies to a data def. I've
attached the xml for the data def and the nav format in txt format.
Support Staff 36 Posted by Ryan Griffith on 11 Jul, 2012 03:07 PM
Charla,
Perhaps you can try the following:
Change:
To:
37 Posted by Charla on 11 Jul, 2012 03:36 PM
Identical error:
An error occurred: Error on line 75: The entity name must immediately
follow the '&' in the entity reference.
You may choose to retry the operation <>. If the problem persists, please
contact a system administrator.
The error has been logged to the system console.
Home <https://cmsprod.lamar.edu/home.act>
Macro:
@@@
#macro (outputItemPath $node)
#set ($itemPath = $node.getChild("link").value)
#if ($node.getName() == "first-level-link")
#set ($itemPath = $node.getChild("content").value)
#elseif ($node.getName() == "second-level-link")
#set ($itemPath = $node.getChild("content").value)
#elseif ($node.getName() == "third-level-link")
#set ($itemPath = $node.getChild("content").value)
#end#set ($itemTitle = $node.getChild("title").value)
#set ($itemTitle = $_EscapeTool.javascript($node.getChild("title").value))
#if ($node.getName() == "system-folder")
#set ($itemPath = $itemPath + "/index")
#elseif ($node.getName() == "system-symlink")
#set($itemTitle = $_SerializerTool.serialize($node.getChild("title"),true))
#end
<a href="${itemPath}">${itemTitle}</a>
#end
@@@
On 7/11/12 10:07 AM, "Ryan Griffith"
<[email blocked]> wrote:
>#set ( $itemTitle =
>$_SerializerTool.serialize($node.getChild("title"),true) )
CONFIDENTIALITY: Any information contained in this e-mail
(including attachments) is the property of The State of Texas and
unauthorized disclosure or use is prohibited. Sending, receiving or
forwarding of confidential, proprietary and privileged information is
prohibited under Lamar Policy. If you received this e-mail in error,
please notify the sender and delete this e-mail from your system.
Support Staff 38 Posted by Ryan Griffith on 11 Jul, 2012 03:39 PM
It looks like there are similar lines, you may have changed the wrong one. Try the following:
39 Posted by Charla on 11 Jul, 2012 03:47 PM
Sorry, this macro in my format has no spaces and it's difficult to see
where to put text.
That fixed the & issue but broke my javascript escape. When someone type
a apostrophe in a title, it breaks my js nav.
On 7/11/12 10:39 AM, "Ryan Griffith"
<[email blocked]> wrote:
>## #set($itemTitle = $_EscapeTool.javascript($itemPath))
CONFIDENTIALITY: Any information contained in this e-mail
(including attachments) is the property of The State of Texas and
unauthorized disclosure or use is prohibited. Sending, receiving or
forwarding of confidential, proprietary and privileged information is
prohibited under Lamar Policy. If you received this e-mail in error,
please notify the sender and delete this e-mail from your system.
Support Staff 40 Posted by Ryan Griffith on 11 Jul, 2012 06:33 PM
This might be a long shot, but you could try the following:
I updated the following:
first-level-navand notsystem-symlinkorsystem-folderRyan Griffith closed this discussion on 18 Oct, 2012 08:19 PM.