6

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>
                    }
                } 
        }
2
  • 1
    This has now been resolved: updated the modified code above. I had to add<p> tags to each field items to make sure all site edit tags worked.
    – guest_2014
    Commented Jun 4, 2014 at 13:26
  • 1
    Doesn't need to be <p>, any element will work, even non-HTML (though that may mess up display)
    – Nuno Linhares
    Commented Jun 5, 2014 at 1:05

1 Answer 1

4

As you've already discovered, the Experience Manager comment tags need to be wrapped with some HTML element per field in order that the UI can display them correctly and allow editing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.