November Happy Hour will be moved to Thursday December 5th.

Hyperlinks with Custom Text Approach

Vote:
 

Afternoon all,

We've been working on a fresh site build for a few months now and I wanted to get some views on something that has been bugging me for the duration: hyperlinks.

Since neither the URL nor the Page Reference property allow you to specify any custom link text as with the Link Collection, we have been using two fields (a string link text and a Url for link destination). While cumbersome, this is the only solution we could come up with without creating a custom property, but it has one significant flaw that I've not found my way around yet: when page editing you aren't able to edit both link and text in one sidebar view, so you either provide an additional element in edit mode to attach the link EditAttributes to or you tell your editors to manage links in forms view. e.g.

<a href="@Url.PageLinkUrl(Model.Link)" title="@Html.PropertyFor(m => m.LinkText)">
                <i class="icon" @Html.EditAttributes(m => m.Link)></i>
                @Html.PropertyFor(m => m.LinkText)
            </a>    

How has everyone else been handling links with custom text? I feel like we must be missing something key.

#69508
Mar 26, 2013 13:40
Vote:
 

I would suggest using a custom block type that you use as the type for your link properties. That way editors will be able to edit both values at once and you can have a simple template for it that renders the link with the custom text.

#69509
Mar 26, 2013 13:51
Vote:
 

Simple but effective, thanks!

#69511
Mar 26, 2013 15:17
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.