A long overdue overhaul

-   Oct 01, 2012 -   Software -  

I haven’t blogged much over the past few years. Part of that was a focus on other interests to be sure, but more recently, it was the blog itself that was keeping me from blogging.  BlogEngine.NET has been good to me but things were feeling a bit long in the tooth in a few areas.  I had not updated to 2.0 or beyond and was really a bit unsure what I’ve wanted to do with my blog.  I’ve had lots of ideas for updates, tweaks, and the like.  Every time I would think about writing, I’d think about things I wish my blog handled better or were just different. Avdi Grimm wrote about something similar a while back and it sounded a lot like where I’ve been at. Before I started doing technical blogging in ~2006-2007, I spent literally years hamstrung by my need to come up with “the perfect” blogging platform. I’d come up with some topic I wanted to blog about, then that would lead to thinking about that blog system I wanted to write, and I’d wind up writing nothing. While Avdi was writing about his reasons for using WordPress and how this keeps him from fiddling with it, to me it was the voice of someone feeling the same things I was but making some choices to get the focus back on the writing. As one of the original BlogEngine devs, I wasn’t willing to give up dabbling with blogging tool at all, but I needed to make some choices to remove the reasons I wasn’t writing.  Over the weekend, I made a list of my “must have” features, pulled the source and spent a few hours making the changes I felt were at the top of my list of need to have.  I cleaned it up with a simple responsive theme and here it is.  BlogEngine.NET 2.6 has a lot of new things I was missing, including a few of the items on my list. Pulling up the code was like pulling on an old sweatshirt that you have buried in your closet.  Familiar, comfortable, and welcoming.  Not sure my changes will or even should go in the BE source, but it isn’t something I’m even thinking about in the short term.  I’m now thinking about writing again.

 BlogEngine.NET Installation Screencast

-   Feb 02, 2010 -   Screencasts, BlogEngine.NET -   ,

Well, it is that time again.  I celebrate every release of BlogEngine.NET with a new installation screencast.  The process is the same as before, but it is good to have a fresh version for people new to BlogEngine. For those who prefer written instructions, check out the BlogEngine Documentation.  There is a lot of good information out there along with troubleshooting information. If you have questions or need help, please check out the BlogEngine.NET documentation and forums.  Most of the common questions and answers are found by looking in the docs or searching the forums.

 BlogEngine.NET 1.6 Released

-   Feb 01, 2010 -   BlogEngine.NET -   ,

This evening, the BlogEngine.NET team released version 1.6.  You can head on over and download it now. This release has a lot of important updates rolled into it including enhancements to the comment system and widget zones.  This release has lots of little touches that improve many of the existing features.  Be sure to check out the details on the main site for the highlights and release notes. A huge thanks to the Ruslan, Ben, and Russell who put in a ton of effort to make this release happen.  It was a great effort.  You guys rock!

 BE Theme Tip: Adding default images for each category

-   Jul 28, 2009 -   BlogEngine.NET, Development -   ,

When I looked around at blog templates on different sites, I’m running across more and more templates that expect each post to have an image or two with it in the display template.  I think it looks great, but I also think I would post even less if I had to have images in the certain sizes for each and ever post I wanted to make. In thinking about it however, I decided it would work out pretty well for me if I picked out an image for each category and let my theme put the correct image into the template as needed.  In my theme, I have only 2 image sizes and there are different enough that I decided to make images for both sizes, but if they were more similar, you might be able to get away with a single image and resizing it on the fly. Since these images are part of how the post is displayed, the work for this is part of the PostView.ascx of your theme.  I used the code behind file for this as well and added the following into my custom PostView class. 1: protected string CategoryImage; 2: protected string FeaturedImage; 3: protected void Page_Load(object sender, EventArgs e) 4: { 5: string imageRoot = Utils.AbsoluteWebRoot.ToString() + 6: "themes/myTheme/images/categories/"; 7: string catImageName; 8: if (Post.Categories.Count > 0) 9: catImageName = Post.Categories[0].Title.Replace(".", ""); 10: else 11: catImageName = "NoCategory"; 12: 13: CategoryImage = imageRoot + catImageName + ".jpg"; 14: FeaturedImage = imageRoot + catImageName + "Featured.jpg"; 15:  16: base.Page_Load(sender, e); 17: } Now I had a CategoryImage and FeaturedImage url string that I could use in my PostView.ascx to show the correct image for each post. 1: <img src="<%=CategoryImage %>" alt="<%=Server.HtmlEncode(Post.Title) %>" /> It is a relatively simple trick, but gives you some neat customization on your blog.  This concept can be used to do countless customizations to the PostVIew, CommentView and even the Site.Master pages in your theme.

 BE Theme Tip: Make the front page look different

-   Jul 25, 2009 -   BlogEngine.NET, Development -   ,

I spent some time over the past few days working on a new theme for this blog.  It had been a while since I had made a BlogEngine theme, but the process is still the same as it was 2 years ago.  It is a fairly easy process and it really allows for a lot of customization with just the smallest amount of code. I thought I would share a few of the techniques I used in making this theme over a few blog posts.  Hopefully, they will come in handy for someone making their own theme and maybe inspire some more interesting themes in the BlogEngine realm. One of the most interesting parts of the new theme is the different look on the front page of my blog.  The front page on a BlogEngine blog is usually a list of posts (although this can be overridden to be a particular page in the admin section).  The list of posts or post list is simply a display of a set number of posts one after another.  Each post is displayed using the PostView.ascx of the specific theme. The number of posts depend on the settings you have chosen in your admin section.  There is also a setting that determines if the post is displayed in full in the post list or if just the description (or first so many characters) are displayed. Armed with this basic information, we know that all we need to do is put a little custom code in the PostView.ascx to change the look of the page based on what type of page it is.  In my case I really only care if I’m displaying the post list or not, but you could easily write your code to check for a specific page, a particular categories or whatever. The first thing I did was to make an enum called PageStyle with 3 values (Page, Front, and Featured).  Page is for general formatting.  Featured is the top item on my front page and Front is the other items on my front page. I then added a ViewStyle variable to my theme’s PostView class in PostView.ascx.cs and the code in in the page load to set ViewStyle based on what page is being displayed.  A trimmed down snippet of this code is below. 1: protected PageStyle ViewStyle; 2:  3: protected void Page_Load(object sender, EventArgs e) 4: { 5: string path = Request.RawUrl.ToLower(); 6: if (path.LastIndexOf('/') > -1) 7: path = path.Substring(path.LastIndexOf('/') + 1); 8: if (path.StartsWith("default.aspx") || path.StartsWith("blog.aspx") || path == "") 9: { 10: ViewStyle = PageStyle.Front; 11:  12: // Latest Post? 13: BlogEngine.Core.Post temp = Post.Next; 14: if (temp == null) 15: ViewStyle = PageStyle.Featured; 16: } 17: else 18: { 19: ViewStyle = PageStyle.Page; 20: } 21:  22: base.Page_Load(sender, e); 23: } Now that I have ViewStyle set, I can use this in my PostView.ascx page to dramatically change the look of the html that will result for the different type of pages being called.  I’ve put a few samples in the snippet below. 1: <% if (ViewStyle == PageStyle.Page) { %> 2: <div class="post-page"> 3: ... 4: </div> 5: <% } %> 6:  7: <div class="<%=ViewStyle == PageStyle.Page ? "post-title" : "junk" %>"> 8: ... 9: </div> Personally, I like changing the classes of my divs and span tags where possible and use CSS to make the changes. Sometimes however, I’ve needed to actually use an if block to make the display look as I’d like. A quick note for those trying this with an existing theme.  Most themes I’ve seen do not have a code behind file for the PostView.ascx.  You can make one, but make sure you reference it in the PostView.ascx file and that your cs file inherits from BlogEngine.Core.Web.Controls.PostViewBase.  If you forget this, you won’t get anything to work. Hopefully, this is helpful to someone.  If you have questions or I need to be more clear, let me know in the comments.