Vanderlay.Classy works for some content types but not pages?

Topics: Customizing Orchard
Jun 2, 2011 at 2:09 PM

Hi, I just installed Vanderlay.Classy.

First, great module!... but I think that this functionality should be core to Orchard, rather than a module.

Second, I also installed the "Recent Content" module to display Recent Posts from multiple blogs on my site:

I have applied the "Custom Css" part to both "Recent Content" and "Page" types. In the admin editing pages I have the CustomID and CustomCss fields on both types. However only the "Recent Content" is picking up the custom id/css

"homepage-recent" & "homepage-recent-css", whereas I really need the page to pick up a custom id/css "homepage" & "homepage-css" so that I can hide the awkward title/date part.

Any ideas what I might be missing?

Jun 2, 2011 at 3:36 PM

To hide stuff, don't use CSS, use placement. It's better not to go to the grocery than going to the grocery and buy nothing.

In order to target the homepage, in placement info, use <Match Location="~/" >

If placement appears not to be a good solution, you can also change the template itself, based on the location, using the Url Alternates module. Enable it, then look into Shape Tracing to see the new alternates per url.

Jun 5, 2011 at 1:59 PM

I've fixed up this particular page with, thanks for the tip.

However, I would still like to be able to target specific pages with unique css via id or class attributes. Can you confirm a bug in the module/platform or identify any reason it might not be working?

Jun 6, 2011 at 7:11 PM

Can you give more details on how you are trying to do it?

Aug 3, 2011 at 11:15 AM

I can confirm that this very useful module doesn't work with pages, and it would be really nice if it will work.

Aug 4, 2011 at 3:58 AM

Actually, I can confirm that it does in fact work for pages :) The thing is, your content template needs to adhere to a pattern that allows the tag for the content item to be enhanced externally. Unfortunately the default content.cshtml does not do that. Here is what I use in my theme as my content.cshtml (the change is the stuff with tag):

@using Orchard.Utility.Extensions;
	Layout.Title = Model.Title;
	var contentTypeClassName = ((string)Model.ContentItem.ContentType).HtmlClassify();

	WorkContext.Layout.SubPageTitle.Add(Model.Header, "10");

    var tag = Tag(Model, "article");
		@if (Model.Meta != null) {
		<div class="metadata">
	@if(Model.Footer != null) {

Aug 5, 2011 at 6:46 AM

Thats works great. Thanks!

But your content.cshtml missing logic to display page title :) I;ve added this to <header> and it works now perfectly.

@if (Model.Header != null)

Aug 5, 2011 at 6:58 AM

Ah yes, you are absolutely correct. This comes from another unrelated change I had to make and I forgot to restore it.

Feb 29, 2012 at 1:09 AM

I have the same problem.

I downloaded the Vanderlay.Classy module. Added 'Custom Css' part to my page and another widget to test. Added this code to content.cshtml file of my theme. But it still doesn't work. I can see the custom class was added to my widget, but not the body tag of the page.  I want each page to have a different body Css class. 


Feb 29, 2012 at 1:43 AM

Attach a debugger and put a breakpoint in there to see what's going on.

Feb 29, 2012 at 11:26 PM

I had added both document.cshtml and content.cshtml to my theme. The body class is fetched in content.cshtml, but I think it is disregarded in document.cshtml. I removed document.cshtml to see if that would make any difference, but it didn't.

Mar 2, 2012 at 4:28 AM
Edited Mar 2, 2012 at 4:31 AM

I have moved it to content-page.cshtml. Like before, it does fetch the class but doesn't render it ultimately. It works for other content types but not the body tag. Am I missing something here?

Mar 2, 2012 at 11:33 PM

document.cshtml is a wrapper for the layout shape. Layout is probably where you will want to act.

Mar 4, 2012 at 11:49 PM

Hi Bertrand,

Not sure if I am the only one who faces this problem...but, after creating a few templates I managed to get the custom class assigned to the body tag. It works like a charm but only for a short while. Suddenly, after a while, it stops fetching the class, like it has a mind of its own! If I check again after a few hours, it works fine again but only for a short while. (!)

Mar 4, 2012 at 11:52 PM

You probably have a caching issue.

Mar 5, 2012 at 12:16 AM

Can you please be kind enough to guide me where to look at or what to fix? Like, if there is a cache value for the custom class, why wouldn't it fetch it for a few hours and only work for a few mins instead? 

Mar 5, 2012 at 2:19 AM

I can't know what kind of caching is active on your site.

Mar 5, 2012 at 3:24 AM

Oh well, then there is none! I am working off the source code 1.3 and trying to learn the ropes.

Mar 5, 2012 at 8:00 PM

Perhaps you could paste in here your razor view in which you render the css class? Also, you could write some Razor code that asserts that the class is not-empty (if it is, throw an exception). Then you know for sure if there's a caching issue or not.