2013-08-24 46 views
3

所以標題幾乎全部都說明了。顯示媒體庫選擇器在Orchard CMS列表中選擇項目視圖的字段圖像

我正在使用Orchard CMS v1.7。我創建了自己的內容類型(產品類別) - 這與頁面基本相同,但也有一個額外的字段(媒體庫選取器字段),允許我選擇並顯示單個圖像 - 這將顯示在列表項目視圖以及主頁面內容。

我使用投影頁面來顯示所有內容類型「ProductCategories」。這很好,並且如預期的那樣。

我現在想在查看投影頁面時在ProductCategories列表中的每個項目內顯示這個附加圖像。

使用形狀追蹤我爲我的列表項目創建了一個替代品。

默認情況下,這看起來是這樣的:

@using Orchard.Utility.Extensions; 
@{ 
    if (Model.Title != null) { 
     Layout.Title = Model.Title; 
    } 

    Model.Classes.Add("content-item"); 

    var contentTypeClassName = ((string)Model.ContentItem.ContentType).HtmlClassify(); 
    Model.Classes.Add(contentTypeClassName); 

    var tag = Tag(Model, "article"); 
} 
@tag.StartElement 
    <header> 


     @Display(Model.Header) 

     @if (Model.Meta != null) { 
      <div class="metadata"> 
       @Display(Model.Meta) 
      </div> 
     } 
    </header> 
    @Display(Model.Content) 
    @if(Model.Footer != null) { 
     <footer> 
      @Display(Model.Footer) 
     </footer> 
    } 
@tag.EndElement 

我現在堅持 - 我不知道我怎麼顯示關聯到該項目的形象。

我一步通過我的代碼檢查Model傳遞到我的自定義列表項目視圖和一些奇怪的事情發生的內容...

當模型被裝載在沒有ListLogo內。 - 看到第一個快照..

- Notice there is no ListLogo within the object -

然而,那一刻我通過我的@if (Model.Meta != null)步驟ListLogo現在可以在對象上找到,但它仍然是空的 - 如本快照。

- i now have ListLogo though it's empty -

如何顯示有關該內容條目圖像 - 只有1了。

我是否需要重寫實際列表本身的創建?如果是這樣,你能給我指針嗎?

在此先感謝。

回答

5

bah - 所以再次,這一切都歸結到我的主題Placement.info文件。

我在我的DisplayType="Summary"中添加了對​​的引用,它的工作原理類似於魅力。

E.G我placement.info在我的主題有這一個項目在我的名單

<Match DisplayType="Summary"> 
    <Place Parts_Common_Metadata_Summary="-"/> 
    <Place Parts_Title="-"/> 
    <Place Fields_MediaLibraryPicker="Content:1" /> <!-- this adds the field.. -->  
</Match> 
相關問題