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.

 BlogEngine.NET 1.5 Upgrade Guide

-   Apr 13, 2009 -   BlogEngine.NET -   ,

With the final release now out the door, I want to take a little time to walk you through the process of upgrading your version of BlogEngine.NET. As you’d expect, the upgrade process is fairly easy, however, I try to go into lots of details to cover as many different scenarios as I can.  While the following guide is long, I fully expect, most of you will be able to skip a section or two along the way and be upgraded quickly and painlessly. This guide was written from the perspective of upgrading from 1.4.5 to 1.5.  If you were one of the people who tried out the 1.5 release candidate, this will work fine for you too.  If you are using an older version, it would be best to read this over, but also to look at some of the past upgrade guides to learn about some other important changes. 1. Backup This is my favorite step in the process.  If you do this, there should be no fear of upgrading and in the horrific case of a problem, you can just revert back to your backup. If you can’t bring yourself to backup the whole blog, be sure to at least get your App_Data folder, your themes and extensions, and your web.config file. 2. Download BlogEngine.NET 1.5 (web) I’m sure you have already done this step, but if you haven’t, this is the time.  You can download it here. Once you have it downloaded, go ahead and unzip it and then remove the read only check in the properties. (apply to all subfolders and files). 3. Update your data and configuration If you use the default XML data storage, you can move along to the next step.  If you are not sure, you are likely using the default option, so you should move on too. Welcome database person.  It is time to update your database.  It is a small change, but required. In the newly downloaded BlogEngine folder, you will see a Setup folder. In this folder is a folder for each of the supported databases, MySQL, SQLite, SQL Server, and VistaDB.  Find the one for the database you use and open the folder. There is a readme.txt in the folder with instructions on upgrading.  There should also be an upgrade script for your database and a new web.config file that you will need to put in place. The web.config has changed since 1.4.5 and it is easiest to just use the new version that is included in the download and add your connection string info to it.  If you made other changes, than you are on your own. If you are using the SQLMembershipProvider and SQLRoleProvider, you’ll want to make sure you make this change in your web.config.  We are defaulting to the DbMembershipProvider and DbRoleProvider to keep things simple. 4. Update your web server We should be ready to start copying files to our web server.  If you skipped step #1, this is your last chance to do that. I find it smoothest to remove all the blog files and folders I don’t plan to keep first.  Since I have a backup, I keep my App_Data folder and remove the rest.  (I will put back my themes, extensions, and widgets later.) Uploading to a remote web server can take a while.  Be patient. 5. Security This is not something to be concerned about unless you are upgrading from an older version, but I wanted to mention it for those coming from 1.3.1 or older.  Please read the old guide to get the scoop.  If you are a more current user, you can hold your head up high and move on to step #6. 6. Themes and Extensions If you are using a custom theme, you will need to upload it right away.  Any special widgets or controls you might be using will need to be there too for the theme to start up properly. Make a note of what files you are putting out to your web server in case you have issues.  If trouble arises, I’d start by switching themes to the Standard theme to make sure the default setup is working for you. 7. Open your site in your browser It will take a few moments the first time around, so don’t panic if it does not come up right away.  In a moment or two, if everything is well, you will see your blog. If you have an error or display issue, take a look at the troubleshooting section below. 8. Clean up If you didn’t copy all any themes, widgets, or extensions out, now is the time to do so.  Refresh your browser once they are copied to have them take effect. 9. Theme updates If you are not using one of the default themes, you’ll want to take a look at the comment form.  A few tags were changed here and you may want to change the css for the comment section.  Also, if you plan on enabling Nested Comments (see the Settings page), you will want to make some adjustments to your theme to handle it.  See the comment view documentation page on our wiki. Enjoy the goodness that is BlogEngine.NET 1.5! Troubleshooting Don’t fret.  Any problems you’ve had have likely been seen before.  Below are a few common things to check.  If these don’t help, please head on out to the BlogEngine forums.  If you can’t find the answer searching there, make a new post and ask for help. Compile Errors: Are you running MySQL, SQLite, or VistaDB?  Are you sure you are using the version of the DLL listed in the web.config? If you are using MySQL or SQL Server, do you have the correct connection string in your web.config? Did you clean out all the old BlogEngine files or did you just overwrite them?  Did an old file get left in place? Did your FTP program miss a few files?  It would be a good idea to make sure everything is uploaded. Did you have a customized web.config before?  Did you merge the changes in?  Or are you using your old web.config? BlogEngine Issues: Can’t login?  Were you using the SQLMembership Provider before and forget to configure it?  If you are a DbMembership or XMLMembership user, you can clear out the password and log in with “admin”. An application restart might help if you are locked up. If you are still having an issue, please head on over to the forums.  Search first as someone has likely already had the same issue, but if not, please ask. Good luck and Happy Blogging!