I am using the following code to render a set of links. I am however not able to edit the internal_link field through site edit. It is allowing only one field to be editable though I have provided site edit tags for all fields.
In this case...only title is editable.When I remove the site edit tag for title, the inter_link becomes editable.
What am I doing wrong? Any help would be very much appreciated:
@if (lnk.ContainsKey("internal_link"))
{
if(lnk["type"].Value == "Open New Window")
{
var lk = lf.ResolveLink(lnk["internal_link"].LinkedComponentValues[0].Id);
if(lnk.ContainsKey("image"))
{
@Html.SiteEditField(Model.Component, lnk["internal_link"])
<a href="@baseurl@lk" target="_blank">
@Html.SiteEditField(Model.Component, lnk["image"])
<img src="@lnk["image"].LinkedComponentValues[0].Multimedia.Url" alt="@lnk["image"].LinkedComponentValues[0].Title" />
@Html.SiteEditField(Model.Component, lnk["title"])
@Html.Raw(lnk["title"].Value)</a>
}
}
if(lnk["type"].Value == "Same Window")
{
var lk1 = lf.ResolveLink(lnk["internal_link"].LinkedComponentValues[0].Id);
if(lnk.ContainsKey("image")){
<p>
@Html.SiteEditField(Model.Component, lnk["internal_link"])
<a href="@baseurl@lk1">
@Html.SiteEditField(Model.Component, lnk["image"])
<img src="@lnk["image"].LinkedComponentValues[0].Multimedia.Url" alt="@lnk["image"].LinkedComponentValues[0].Title" />
@Html.SiteEditField(Model.Component, lnk["title"])
@Html.Raw(lnk["title"].Value)</a></p>
}
if(!lnk.ContainsKey("image")){
@Html.SiteEditField(Model.Component, lnk["internal_link"])
<a href="@baseurl@lk1">@Html.SiteEditField(Model.Component, lnk["title"])
@Html.Raw(lnk["title"].Value)</a>
}
}
}
//UPDATED CODE:
@if (lnk.ContainsKey("internal_link"))
{
if(lnk["type"].Value == "Open New Window")
{
var lk = lf.ResolveLink(lnk["internal_link"].LinkedComponentValues[0].Id);
if(lnk.ContainsKey("image"))
{
@Html.SiteEditField(Model.Component, lnk["internal_link"])
<a href="@baseurl@lk" target="_blank">
<p>@Html.SiteEditField(Model.Component, lnk["image"])
<img src="@lnk["image"].LinkedComponentValues[0].Multimedia.Url" alt="@lnk["image"].LinkedComponentValues[0].Title" /></p>
<p>@Html.SiteEditField(Model.Component, lnk["title"])
@Html.Raw(lnk["title"].Value)</p></a>
}
}
if(lnk["type"].Value == "Same Window")
{
var lk1 = lf.ResolveLink(lnk["internal_link"].LinkedComponentValues[0].Id);
if(lnk.ContainsKey("image")){
@Html.SiteEditField(Model.Component, lnk["internal_link"])
<a href="@baseurl@lk1">
<p>@Html.SiteEditField(Model.Component, lnk["image"])
<img src="@lnk["image"].LinkedComponentValues[0].Multimedia.Url" alt="@lnk["image"].LinkedComponentValues[0].Title" /></p>
<p>@Html.SiteEditField(Model.Component, lnk["title"])
@Html.Raw(lnk["title"].Value)</p></a>
}
if(!lnk.ContainsKey("image")){
@Html.SiteEditField(Model.Component, lnk["internal_link"])
<a href="@baseurl@lk1"><p>@Html.SiteEditField(Model.Component, lnk["title"])
@Html.Raw(lnk["title"].Value)</p></a>
}
}
}
<p>
, any element will work, even non-HTML (though that may mess up display)