简体   繁体   English

Umbraco页面名称而不是页面ID

[英]Umbraco page name instead of page id

I am pondering over an Umbraco related problem. 我正在考虑与Umbraco有关的问题。

In the admin I am allowing the uploading on an image using the Upload Type Property 在管理员中,我允许使用“上传类型”属性在图片上上传

Then the user can select a page on the website using the Content Picker Type Property. 然后,用户可以使用“内容选择器类型”属性在网站上选择页面。

The image is then wrapped with the following anchor tag code 然后使用以下锚标记代码包装图像

The problem is that the link returns the id of the selected page ie http://listerivf.whclpreview.com/1107 and not http://listerivf.whclpreview.com/egg-donors.aspx , can anyone help me with the anchor tag code href code, thanks! 问题是该链接返回所选页面的ID,即http://listerivf.whclpreview.com/1107而不是http://listerivf.whclpreview.com/egg-donors.aspx ,任何人都可以通过锚点帮助我标签代码href代码,谢谢!

<a href="<%= umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("imageLink").Value %>">
      <umbraco:Image runat="server" field="au1" width="302" height="215" class="thumbnail" /></a>

Here is how I handle these images. 这是我处理这些图像的方法。 I often want to show my image markup (often has wraping visual elements) only if an image is selected. 我经常想仅在选择图像后才显示图像标记(通常具有环绕的视觉元素)。 So I use: 所以我用:

@{
    var myImageSrc = Utilities.GetMediaSrcOrEmptyString(Model.image.ToString());
}

This function is: 该函数是:

public static string GetMediaSrcOrEmptyString(string nodeId)
{
    if (nodeId != "")
    {
        dynamic mediaItem = new DynamicNode(Convert.ToInt32(nodeId));
        return mediaItem.umbracoFile;
    }
    return "";
}

Then I can use the following to print my markup: 然后,我可以使用以下命令打印标记:

@if (myImageSrc != "")
{
    <div class="myClassForImage">
        <img src="/ImageGen.ashx?width=465&image=@imageSrc" width="465" alt="@Model.someField"/>
    </div>
    <br/>
}

Very simple, but quite usefull! 很简单,但是很有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM