This project is read-only.

Where is the file (cshtml) that controls how the blogs are displayed?

Topics: Customizing Orchard, General, Writing themes
Nov 6, 2011 at 2:10 PM

Hi there,

I am just beginning customizing a theme, i based it on the Time Machine but i have my own Layout.cshtml.

Its taking form :-) Using standard HTML 5 etc ...


The problem i have now, it looks pretty good but it appears the cshtml (layout) doesn't control the layout or even what is displayed for the blog post.


Where is this file? I downloaded the source for 1.3. There are many projects.


Is the idea to open up the file (if i could find it) and edit it ? or copy it into my theme directory which i presume then it would override?


If anyone can point me in the right direction that would be great.


I think there a few files??  I presume one that displayed the blog items on the home page and the individual blog item.


I was hoping to find some document explaining this process, i checked out the docs and maybe i am just missing it :-)


Any help really appreciated


Thanks in advane


Nov 6, 2011 at 2:27 PM

I found something called List.cshtml which was in a directroy called Blog in modules..


So i created a directory called Blog under my theme's view directory and copied the file here...


then i edited it and changed something, but nothing changed...


So this is probably not the correct way.

Nov 7, 2011 at 11:11 AM

Blog posts and items are regular Content Items. They go through a special display process whereby they are constructed from a number of different parts, each of which contribute their own pieces of the display, You can create a file in your theme's root directory to control which parts display and in what order. Then you can override individual templates to change HTML in custom ways. You can use the Shape Tracing module to discover which bits of the display come from what files.

If you give an example of a specific way that you want to alter the rendering, I can tell you more exactly how to achieve it.

Nov 7, 2011 at 11:13 AM

By the way, copying templates into your theme (in the ~/Views folder) is the correct way to override templates. You don't want to alter templates directly in a module or in Orchard because they'll get overwritten on an upgrade. Usually a template should be in the same relative path under ~/Views, but with controller views it gets more complicated as you need to create a folder named after the area (module) the template is from (this will be why the List template isn't working, possibly the folder should be Orchard.Blogs).

Nov 7, 2011 at 11:48 AM

Hi randompete,


Great! Yep now see if.


Basically what i would like to do if change the rendering of the blog item and blog item(s)..


In blogitem, (a single blog) i would like to add icons for twitter, facebook, google +1 etc  and a few more things.

Also i would like to style each item.


From what i see it appears the blog summary is made up of more than one template. Where do i find a list of each one? The process that it goes through to display the items?


Currently i am just overriding Views, i presume it is possible to override controllers as well??? This is a case of just copying the file?


So all content items are templates, where are these normally stored, in which project ?  Core?


Thanks once again for your help.


Nov 7, 2011 at 12:23 PM

Content Items are built up from many templates (read my post again, I explained this). Each module can contribute new templates to a content item, using a mechanism called Content Parts.

There's already a module on the Orchard Gallery for adding Facebook, Twitter etc. icons to content - you'll probably want to just use that, and also have a look at its code to see how it works (also, read the various tutorials in Orchard's documentation about writing Content Parts).

For styling, just use CSS. It's pretty rare that you should need to alter any HTML. But, on the occasions when you do, you have to enable the Shape Tracing module to find out which templates come from what files (it's sort of like Firebug for Orchard templates).

Finally, controllers can be overridden but it's much rarer that you'd want to do so, and usually you wouldn't do so just to change rendering. It's also slightly trickier that overriding a view, there's a certain amount you need to understand about Orchard first, and it's generally not advisable unless you know exactly what you're doing.

Nov 7, 2011 at 12:28 PM

Great, yep ok got that... going to have a play now :-)


Thanks once again