This project is read-only.

How to modify *where* tags go in a blog

Topics: Customizing Orchard, General
Mar 5, 2012 at 5:45 PM

I have downloaded and installed the dev tools for Orchard, so I can examine shapes. I can see many nifty things I had trouble figuring out before, but one still stumps me.

I am assuming that the same piece that assembles the “Blog entry previews” is the same piece that assembles the entire blog entry itself when viewed on its own page. At least, that is what I am seeing via the Shapes tool.

However, what I cannot seem to find is that one portion that handles everything from the H1 to the tags. I can see where it is brought in, in the file


as there is the


That sits between the <header> html tag and the <div class="metadata"> that handles the publish date and the comment count. However, I cannot seem to find where the Model.Header brings its information in from, and how it determines what to bring in.

You see, I want to modify the location of tags. Since both the previews as well as the full blog posts appear to be handled by Content.cshtml (as previously mentioned), removing tags from the Model.Header will remove it from that location in both display formats. And if I put the tags at the end of the blog post itself, they won’t show up in the previews because the previews truncate the blog posts to 200 characters (the default).

My main problem is how to find out *where* the tags are shoehorned into Model.Header, and how to modify it. Suggestions?

And as for putting them at the end of the blog posts themselves… suggestions? I would prefer if they did not show up in the list of blog entries (the blog summary page which is usually the front page of a blog), but as long as they do not show up between the title and the meta, I can handle having them appear after the truncated content (not ideal, but I am willing to suffer that for now).

Mar 5, 2012 at 5:52 PM

Just to point out, however: I *do* want the tags list to appear in a full blog post, but only at the very end between the end of the blog post and the comments form. That way, I can put a <hr> both before and after the tags list, allowing the list of tags to clearly identify the end of a blog post (right now the blog post itself tends to flow rather unobstructedly into the comment form… making it a bit hard to determine the end of the post).

Mar 5, 2012 at 10:04 PM
Edited Mar 5, 2012 at 10:06 PM

You can do this easily with
In short, the various parts of a blog post content item are assembled via content parts, one of which being the TagsPart.

Now, each content part has a driver: the TagsPart has a TagsPartDriver. It's these drivers that create the shapes that will be rendered.

In the case of the TagsPartDriver, it creates the "Parts_Tags_ShowTags" shape. Orchard determines its placement via With, you can specify at what position in which local zone you want the shape to be rendered.

In your case, you don't want the "Parts_Tags_ShowTags" shape to be rendered at all when the blog post content items are being rendered in a list. When Orchard renders content items in a list, it uses the "Summary" display type. That display type can be used to create a <Match> element in your file:

<Match DisplayType="Summary">
   <Place Parts_Tags_ShowTags="-" />

This snippet says: don't render the Parts_Tags_ShowTags shape whenever the content item its part of is being rendered using the display type "Summary".

To position the  |Parts_Tags_ShowTags" shape at the end of the blog post in "Detail" view, you can say this:

<Match DisplayType="Detail">
   <Place Parts_Tags_ShowTags="Content:after" />

 "Content" is the name of the so called "local zone" of the content item. "after" means what it says: render the shape after all other shapes in the "Content" zone.

Mar 6, 2012 at 8:26 AM

Yup, that did it sfmskywalker. Thanks for the info and the example markup. Your description went a long way to helping me.