English 中文(简体)
Umbraco 5 非常基本 - 如何在宏中装载一个实体( 或实际使用蜂巢)?
原标题:Umbraco 5 Very Basic - How to load an entity in a macro (or actually using a HiveId)?

我创建了我的第一个自定义 Umbraco 5. 1 解决方案。 此时此刻, 我有一个 < 强度 > 内容项目 < / 强度 > ("主页"), 带有 < 强度 > 海关模板 < /强度 >, 上面有 < 强度 > 习惯部分宏 < /强度 > 。 现在, 我如何使用 < code> Umbraco 帮助程序装载一个实体? 我尝试过使用 < code > HiveId 来添加多个 < codead > 构造, 但是我总是收到同样的错误 :

其他参数必须是 " 指导 " 型的参数,才能转换成 " 指导 " CLR " 型,但它是Uri, 值:xxxx

<强 > Macro 部分:

@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework

@{
    //All these fail with the same error message...

    //Based on name:
    var p = Umbraco.GetContentById(
      new HiveId(
        new Uri("content://Homepage")));

    //Based on path
    var p = Umbraco.GetContentById(
      new HiveId(
        new Uri("content://p__nhibernate/v__guid/5a4abe489a2e47858bd2a0580180b683")));

    //With custom Hive provider (I ve added this using a custom tree/section and products show up, so the hive provider works)
    var p = Umbraco.GetContentById(
      new HiveId(
        new Uri("custom://products/1")));
}

最佳回答

Why are you creating a Uri?
The HiveId accepts a string parameter which you can use instead. So does Umbraco.GetContentById(string id)

我是Umbraco 5认证人,我们从未使用过 Uri 的超载 HiveId 构建器。

var p = Umbraco.GetContentById("yourStringHiveIdHere"); //(string overload) or 
var p = Umbraco.GetContentById(new HiveId("yourSringHiveIdHere")); // (HiveId overload)

你从哪儿弄来蜂窝的蜂窝?

问题回答

暂无回答




相关问题
Creating custom content sections with umbraco

I m working on an umbraco website just now and one of the requirements is to have a custom section in the back end that can be used to manage publish smaller micro-sites. I have been able to create ...

MVC and Umbraco integration

I ve followed the steps from http://memoryleak.me.uk/2009/04/umbraco-and-aspnet-mvc.html and integrated MVC in Umbraco with success, but I still have a problem which is critical for me. Is there any ...

Umbraco server error after install

I downloaded umbraco and used the web platform installer. Everything went though okay and it installed SQL Express 2008 and a new directory under the default website in IIS. However when I launch the ...

XSLT, sort and group by year-date

Regarding Umbraco XSLT version 1. I have aprox. 150 news items in XML. Lets say like this (all is pseudocode until I get more familiar with this xml/xslt): <news> <data alias=date>2008-...

Open node in Umbraco programmatically

I have created a dashboard for an Umbraco site and I want to link from it to various node in the tree. From what I can tell Umbraco uses editcontent.aspx?id={thenodeid} and javascript:opencontent({...

Umbraco Back Office Membership Provider

Has anyone had any experience trying to write a custom Membership Provider for the Umbraco back office? I ve run into all sorts of trouble trying to make this happen. You can see some more details ...

热门标签