Html in Macro in static html web part

Glen Deathridge asked on April 28, 2014 11:03

I’ve been trying to inject some HTML into a macro that is used in the static html web part see below. This HTML are <a> tags which should show what is in the QueryString["URL"]

{% if (QueryString["URL"] != null) { #%} <a href='{% QueryString["URL"] %}'> Back to where you came from </a>{% } else { #%} <a href='http://www.open.ac.uk/'> Explore our courses</a> {% } #%}

If the QueryString URL is null then explore our courses link displays fine.If the QS url has some text then <a href='{% QueryString["URL"] %}'> Back to where you came from </a> needs to display but all that displays is <a href>< Back to where you came from </a>

Can this even be done in a macro?

Any help would be very much appreciated.

I am using version 7

Recent Answers


Brenden Kehren answered on April 28, 2014 13:13

Think you're syntax is incorrect. Should be using QueryString.GetValue("URL") != null)

0 votesVote for this answer Mark as a Correct answer

Glen Deathridge answered on April 28, 2014 16:05

No. That part works fine. What I was doing was actually putting two ' like so <a href=''{% QueryString["URL"] %}''> which seemed to be causing the problem. It now seems to work out but a strange thing is happening. After closing the macro input window, you are left with the web part modal window, clicking Apply renders the HTML correctly, but if you click OK to close the window then the HTML looks like it's been re-parsed or something and is then incorrect! If though I redo the work and click OK to close the modal window instead of Apply first everything is OK, a really strange issue. Maybe somebody at Kentico can help out, happy to document this with screenshots.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 28, 2014 17:01

Incorrect syntax will cause your macro to fail. The proper use of QueryString is as I posted earlier. I used this macro without issue in v7 and v8. {% if (QueryString.GetValue("URL") != null) {"<a href='" + QueryString.GetValue("URL") + "'> Back to where you came from </a>"}else{"<a href='http://www.open.ac.uk/'>Explore our courses</a>"} #%}

0 votesVote for this answer Mark as a Correct answer

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