hyperlinksitecoresitecore-mvc

Sitecore MVC and FieldRenderer.Render for Links


I'm trying to render a general link field like this - FieldRenderer.Render(item, "link").

This works as expected but how do I set custom text within the a tag that gets rendered. I want my output to look something like this

<a href="[link from sitecore]">[custom text from another field]</a>

Basically, the text for the link should come from another field on the item.

Thanks


Solution

  • You probably want to try the following:

    @Html.Sitecore().BeginField("Link Field")
    //custom code
    @Html.Sitecore().EndField()