1

Using standard sitecore controls (Link and Text), you can embed a text field within a link in the following way:

<sc:Link runat="server" Field="LinkUrl" >
        <sc:Text runat="server" Field="LinkText" />
</sc:Link>

That will give you the ability to edit the text of one field and link of another field.

I have tried to replicate this using Glass, but have been unsuccessful. Something like this would be good (It doesn't work):

<%= Editable( x => x.LinkUrl,new { Text = Editable(Model,q => q.LinkText,null)}) %>

Is there another way of sorting this out?

There are two options I see if I cannot do this using standard glass functionality:

  1. Change the GlassHtml code
  2. Use Two Fields
4

2 回答 2

4

如果您使用的是 Razor,请使用:

@using (BeginRenderLink(x => x.Link, isEditable: true))
{
    @Editable(x => x.Title);
}     

如果您使用的是 WebForms:

<%using(BeginRenderLink(x=>x.Link){ %>

    <%=Editable(x=>x.Title) %>

<% } %>

麦克风

于 2014-01-23T22:13:34.673 回答
1

如果您使用的是 Glass 版本 3,则不能使用EditableonLinkImage字段。
使用RenderLinkandRenderImage代替。

见这里: http: //glass.lu/docs/tutorial/sitecore/tutorial22/tutorial22.html

Editable 方法是用于使字段可编辑的最基本方法,应与除 Image 字段和 General Link 字段外的大多数页面可编辑字段一起使用

于 2014-01-23T18:41:51.023 回答