This project is read-only.

Replace h1 with h2

Topics: Controls, Themes
Feb 15, 2009 at 1:16 PM
Im new to and I use brightside theme.
I wounder if its possible to replace the header h1-tag for a post with h2-tag if the post is not viewed seperated from the others.
This is the pseudo code for what Im looking for:

If (post is in list) {
} else if (post is viewed in own page) {

I belive that PostView.aspx brightside theme directory. is the file that needs to be modified.

Please help me!

Feb 15, 2009 at 4:49 PM
Here's an example of what you're looking for using the BrightSide template.  The current <h1> in BrightSide looks like:

<h1 class="postheader" ><a class="postheader taggedlink" href="<%=Post.RelativeLink %>"><%=GetColoredTitle(Post.Title)%></a></h1>

It looks like the size of the <h1> text is controlled by the "postheader" css class.  Trying to stay within that framework, the change below uses the "postheader" css class when viewing the blog post by itself and uses "postheaderSmall" when viewing the post in other places (like the front page).

<h1 class='<%= Location == BlogEngine.Core.ServingLocation.SinglePost ? "postheader" : "postheaderSmall" %>' ><a class="postheader taggedlink" href="<%=Post.RelativeLink %>"><%=GetColoredTitle(Post.Title)%></a></h1>

Location tells you if you're viewing the post by itself.  Here's the CSS I used ...

h1.postheader { font-size: 1.5em; color: #6297BC;margin-bottom:0px;margin:10px 0 0 0; }
h1.postheaderSmall { font-size: 1.3em; color: #6297BC;margin-bottom:0px;margin:10px 0 0 0; }
Feb 15, 2009 at 6:23 PM
Thanks alot, I works great! 
I was looking for this:

Location == BlogEngine.Core.ServingLocation.SinglePost

It works, but how is Location defined?
Feb 15, 2009 at 6:30 PM
Location is a property of the PostViewBase class.  The possible values are None, SinglePost, PostList, SinglePage, Feed, Email, Other.  I'm not sure if all those values are being used.

When you're on a single blog post page, Location is set in post.aspx.cs:

postView.Location = ServingLocation.SinglePost;

When you're on the front page, Location is set in PostList.ascx.cs:

postView.Location = ServingLocation.PostList;
Feb 15, 2009 at 6:40 PM
Edited Feb 15, 2009 at 6:41 PM
Sounds like good programming

Here are the result, On singePost h1, otherwise h2. (SEO)