Blog-friendly posts

Topics: Customizing Orchard
Jan 21, 2012 at 6:00 PM

Hello everyone,

I've been using Orchard CMS for a past few weeks and while it is not really newbie-friendly like WordPress or Joomla, I do think it has a great potential.
Having that in mind, I've decided to stick with it and make necessary modifications for my blog. However, I'm still facing a few issues and I was hoping more experienced developers could help me out.

Namely, I was wondering what do I need to edit (my theme is based on default Theme Machine) in order to decide how many characters I want to show before 'read more' (e.g. something that would be wrapped in paragraph tags or so) and how to get selected/uploaded image shown on front page (classic blog style) after uploading it manually or through ImageField (also how do I remove the name of ImageField from showing)?


Jan 21, 2012 at 6:50 PM

If you give some details about things you didn't find so friendly, then Orchard's developers (and 3rd party module developers) can take those into account when planning changes and features. Or it could be that there are already plans in those areas we can let you know about :) Orchard is still quite young and areas of it definitely need to, and are going to, change. Personally I find it very friendly, but I've been working with websites and CMSs for years so it's good to hear a fresh perspective to drive improvement.

Regarding your questions:

1) In the upcoming release (1.4) there will be a new feature called "Projector" which can generate summary lists and lets you choose the excerpt length. If you can't wait that long (the release is only a few weeks away) then you need to override the template Orchard.Web\Core\Common\View\Parts.Body.Summary.cshtml. You override it by copying the file into your theme's Views folder, and you'll see there's a number you can change to set the summary length. Anytime you want to change a part of the page, use the Shape Tracing feature to explore the page and find out the template file it's generated from, and copy that file to your theme (actually, shape tracing has a Create button to do that automatically for you). It's very easy once you get used to it.

2) The easiest way is to create a HtmlWidget (in the Widgets menu of admin), insert the image, and place that widget in the Header area, on the layer called "TheHomePage".

Jan 21, 2012 at 6:57 PM

Hi randompete,

Thanks for reply! Already fixed the first problem!

As for the second one, I didn't mean on static images, but rather on showing of images at front page with every blog post I publish. 

Jan 21, 2012 at 7:52 PM

Can you explain more, do you mean attaching thumbnails to blog posts? Or something else? Do you have an example site you are trying to look like?

And it would be really great to get more detail on how Orchard is "not really newbie-friendly like WordPress or Joomla" ... it's no use making feedback if you don't say what the feedback is ;)

Jan 21, 2012 at 8:11 PM

Yeah, and having those images displayed on front page, like on Engadget, for example.

As for the feedback, I meant that aforementioned solutions give you that kind of faster-start with content, while you do need to spend a little more time to familiarize with Orchard and how it works in order to enable everything you. For example, I had a hard time with finding solution for taxonomies (until I found a great video by Orchard contributor) since I was expecting it be built in or enabled by default.

Another example is obviously the need to edit config files in order to decide how many characters you want to show in post summary. Solution you provided me with is great, but at the same time, it will not show links nor I'm able to precisely control what is being shown (it will always show selected number of characters).

Finally, I do admit that by using Orchard more, I do find to like it more by understanding some design and architecture decisions better.

Jan 22, 2012 at 5:45 AM

Everybody has a different idea about what should be included by default, so you can do three things: include everything and get a horribly bloated monster, include a set of features that may please some but displease everyone else, or you can include the bare minimum and let everyone add what they need from the gallery. That's what we chose to do.

For images in blog post summaries, I use a custom summary template for the body (and there is no need to edit a config file; actually I'm not sure where this is coming from):


    Orchard.ContentManagement.ContentItem contentItem = Model.ContentPart.ContentItem;
    var bodyHtml = Model.Html.ToString();
    var more = bodyHtml.IndexOf("<!--more-->");
    if (more != -1) {
        bodyHtml = bodyHtml.Substring(0, more);
    else {
        var firstP = bodyHtml.IndexOf("<p>");
        var firstSlashP = bodyHtml.IndexOf("</p>");
        if (firstP >=0 && firstSlashP > firstP) {
            bodyHtml = bodyHtml.Substring(firstP, firstSlashP + 4 - firstP);
    var body = new HtmlString(bodyHtml); 
<p>@Html.ItemDisplayLink(T("Read more...").ToString(), contentItem)</p>

Jan 22, 2012 at 5:09 PM

I would like to see next future.

If set the short news length. For example 300 charsets. After it sytem should waiting start of new paragraph.

For example the paragraph is 320 symbols. So system will split is after 300 symbols - that it's not good. It's should be another count, that will allow to add to 300 chars n chars till next paragraph will start.

Jan 25, 2012 at 6:58 AM

I don't see how this is different from using the first paragraph. To be frank, I don't understand at all how this would work. But well, in any case if that's what you want you should just implement it.

Jan 25, 2012 at 11:48 AM

@EDK_ I actually wrote a module for attaching thumbnails to content, however as a newcomer you might find the current version pretty complex, especially as it needs a few other modules installed to work properly. It will be much better in Orchard 1.4 when there are some new features / fixes to make installing dependencies much easier, and I'm making a lot of improvements to make my module easier to use, it should be released around the same time as Orchard 1.4. It's called "Media Garden: Images".