开发者

Displaying single Fields for a custom ContenType in Orchard

I am beginning to study the very nice CMS Orchard and, after reading the basic documentation, I've stumbled in a little hurdle. I've created a new DataType, 'SpecialOffer', which has some dataparts and some text datafields:

ProductName
PhotoURL
Price
Description

I've made a list, made a widget, customized the position.info file and the Views\Fields\Common.Text.cshtml file to change the position and the way the fields are rendered (a img for the photo, prepending € to the price and so on) but this doesn't give me the right amount of customization over the generated html.

I've installed the developer shape tracing module and created an alternate Content-SpecialOffer.cshtml file. This gives me the opportunity to easily customize the HTML around the content, but I have no idea how to get to the single DataItem fields to display them the way I want.

I mean that the whole SpecialOffer object is displayed through

@Display(Model.Content )

and, exploring the model, I've not found a way to write something as, say (pseudocode)

   <div>
    the 
   <span class="name"> @Model.Contentitem.Fields["ProductName"]</span>
     camera costs 
    @Model.Contentitem.Fields["Price"]
    euros
    </div>

I've read this post on SO Custom View For RecentBlogPosts in Orchard

but it does not solves my problem, since it uses the standard properties of blogpost.

another little question: other than in the Documentation page of project orchard and b. LeRoy's http://weblogs.asp.net/bleroy/ where can I study Orchar开发者_开发百科d?

Thanks!

Edit

I've found a way to do it:

@{
    dynamic offer =Model.ContentItem.SpecialOffer;

    }

     <div>
    the 
   <span class="name"> @offer.ProductName.Value</span>
     camera costs 
     @offer.Price.Value
    euros
    </div>

is this the right way?


Yes, that's fine. After the docs and the RSS feed on the home page of orchardproject.net, a major source of information (better than the previous 2) is the source code for the app and modules.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜