how to get the title of the blog post?

Topics: Core, Customizing Orchard, General, Installing Orchard
Mar 11, 2013 at 12:11 PM
Hi,
i want to get the title of the post in content.summary.cshtml to link with twitter icon. but i am not able to get the title of the post in content.summary.cshtml(core/content/views).
can you please let me know how to get the title of the post?
Developer
Mar 11, 2013 at 5:53 PM
I hope you do use a specific alternate instead of editing the core shape!
But you could to the following:
Add this to the top:
@using Orchard.ContentManagement;
Then this where you'd like the title to be displayed:
@((ContentItem)Model.ContentItem).As<Orchard.ContentManagement.Aspects.ITitleAspect>().Title
Coordinator
Mar 11, 2013 at 7:44 PM
Well, there is a more official way, and more generic too, ask for the display text. If it has a Title it will use it.

@Html.ItemDisplayText((ContentItem)Model.ContentItem)
Mar 11, 2013 at 8:58 PM
@Sebastien, and if our content type has not Title part, is there a way to have this interesting extension Html.ItemDisplayText bringing a result from another part in the contentType ?
Coordinator
Mar 11, 2013 at 9:13 PM
Yes, it just needs to implement ITitleAspect. Look for existing implementations of that interface.
Mar 11, 2013 at 10:00 PM
Thanks
Mar 12, 2013 at 12:46 PM
Hi All,

Thanks for your response. My issue get resolved.