Gravatar for candace.kizzie@bshsi.org

Question by asadk, Jan 19, 2018 7:44 PM

Insert Template Field Variable into URL String

I have the following code inside a .cshtml file. I'm trying to call a variable into a URL string for an iframe but when i insert the variable name, it treats it as simple text. What is the proper syntax or method to use to pull the contents of the provider ID coveo field into the URL string?

<div class="btn-appointment-container">
@Html.Partial("~/Views/Search/Components/_Appointment.cshtml")
{{var prvID = raw.@(Model.ToCoveoFieldName("provider id", false));}}
{{var modalURL ="https:site/EmbeddedSchedule?id=" + prvID + "&vt=3000180";}}
{{ print('<div id="scheduling-container"><iframe id="openSchedulingFrame" frameborder="0" class="widgetframe" src="modalURL" style="width:700px; height:500px;"></iframe></div></div>'); }}
</div>
Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Jan 19, 2018 8:39 PM

`print()` is a very bad practice. You should instead use UnderscoreJS output mechanism:

<div id="scheduling-container"><iframe id="openSchedulingFrame" frameborder="0" class="widgetframe" src="{{= modalURL }}" style="width:700px; height:500px;"></iframe></div></div>
0 Reply
Ask a question