How to Use Macros with Double Quotes WITHIN a Link?

Joshua Myers asked on April 26, 2018 18:28

I have currently on this page: https://www.domain.com/landing-pages/programs/abc-program/details

I would like to dynamically place the last section of the URL into a link on this page like this: <a href="/another-page?program=abc-program">Click here.</a>

When I use the following syntax, it doesn't work due to the double quotes that are already surrounding the HREF. <a href="/another-page?program={% CurrentDocument.NodeAliasPath.Split("/")[2] @%}">Click here.</a>

What is the best way around this?

Recent Answers


Brenden Kehren answered on April 26, 2018 18:51

Change the double quotes around the href attribute to single quotes. Should resolve the problem and still be valid HTML. We do it all the time, no issues.

1 votesVote for this answer Mark as a Correct answer

Joshua Myers answered on April 26, 2018 18:55 (last edited on April 26, 2018 18:55)

I had already tried that. It does work the first time you save, but it reverts back to double quotes whenever I go back in to make another other edits to the content block.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 26, 2018 21:30

You must be doing this in a WYSIWYG editor field then. I'd suggest making a change then and not using the WYSIWYG field and maybe just a text area.

1 votesVote for this answer Mark as a Correct answer

Joshua Myers answered on April 27, 2018 20:12

I'm the only programmer within an organization of content editors. They're not going to let me remove the WYSIWYG.

Is there any other way around it?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 27, 2018 20:18

Check out the CKEditor documentation to see if you can make a configuration change on the editor. That's outside of Kentico but you can make a config change in the /CMSAdministration/CKEditor/config.js

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.