I have a template that maps to the following Glass model.
[SitecoreType(AutoMap = true)]
public class MyGlassModel
{
private Link link;
public virtual Guid Id { get; set; }
public virtual Link Link
{
get { return link; }
set { link = AddDocumentParameter(value); }
}
[SitecoreField("Link text")]
public virtual string LinkText { get; set; }
public virtual Guid Document { get; set; }
private Link AddDocumentParameter(Link link)
{
if (!link.HasValue())
{
return link;
}
if (link.Query.Contains("doc"))
{
return link;
}
if (link.Query.Length != 0)
{
link.Query += "&";
}
link.Query += $"doc={Document}";
return link;
}
}
Everything is mapped well, and the doc-parameter is added to the Query property of the Link. Though when I render the link in my view, it's not added.
My view code:
@inherits GlassView<MyGlassModel>
<div class="btn-row">
@using (BeginRenderLink(cta => cta.Link, isEditable: true, attributes: new { @class = "btn btn-primary" }))
{
@Editable(cta => cta.LinkText)
}
</div>
This is what is being rendered though.
<a class="btn btn-primary scEnabledChrome" href="/nl?test=test" sc-part-of="field">
Why is this, and how can I add the doc-parameter?
Edit: This does seem to work, but not in the Experience Editor.
See <a href="/nl?test=test&doc=e39a4342-a209-423a-be1a-0578ec947dff" class="btn btn-primary">test</a>
I guess my question now is, why does this not work in the Experience editor?