This project is read-only.

Page layout different than Post layout

Topics: Themes
Feb 16, 2012 at 6:10 PM

I'm trying to use as a CMS. What I'd like to do is not have the "Categories" and other panels show up on my pages, but I want them on my blog posts.

I've searched posts here and looked at a lot of themes but I don't see any examples. I can't seem to find it in documentation either.

Any suggestions? Just pointing me to a theme that has this implemented will help a lot.



Feb 16, 2012 at 6:40 PM

Take a look at Garland-Revisited/site.cshtml. Here is a code:

bool isPost = Request.Url.PathAndQuery.IndexOf("/post/", StringComparison.OrdinalIgnoreCase) != -1;
bool isPage = Request.Url.PathAndQuery.IndexOf("/page/", StringComparison.OrdinalIgnoreCase) != -1;

string bodyCss = string.Format("sidebars{0}{1}",
       isPost ? " single-post" : string.Empty,
       isPage ? " page" : string.Empty);

Feb 21, 2012 at 7:00 AM

rtur, thanks. 

I found a post ( that uses ASP if statements and modified it to get to the same place. It seems this one using CSS might be more elegant.