1

I am working with an umbraco document type which has a collection of IPublishedContent as a property. This manifests itself in the view as a string which is a CSV of the keys of the objects, which I then have to parse and look up the underlying values using the content helper.

 by @foreach (var author in Umbraco.Content(story.GetPropertyValue<string>("author").Split(',')))
   {
      @author.Name 
   }

As an MVC developer, this feels very wrong. Is there a better way that I am missing? Ideally Umbraco should know that these are actually content items and map them, similar to a navigation property in an ORM.

Would be happy to go with a strongly typed approach, but I cant find much documentation other than to break everything into child actions.

4

1 に答える 1

0

MVC 開発者は、プロパティ エディターの値コンバーター (ドキュメント)を確認する必要があります。story.GetPropertyValue<List<IPublishedContent>>("myAlias")

.GetPropertyValue<>() メソッドは、適切な値コンバーターを使用します。

v7 を使用している場合、それらは「プロパティ値コンバーター」と呼ばれますが、同じように機能します。

値コンバーターを開発して ContentCache を使用する場合は、必ず確認してください (これらはデータベース クエリをトリガーするため、uQuery またはサービスに依存しないでください)。

于 2014-06-16T15:41:20.167 に答える