Use BlogEngine.Net as a Content Management System

by Bobbi Perreault 18. September 2009 00:23
Share on Facebook

I've used BlogEngine.Net for a CMS a few times now and I'm happy with the way it has worked out for the very small business sites that I maintain.   I'm comfortable in this programming environment and so that's why I choose it over WordPress.

Its easy to modify so that each BlogEngine.Net category is directed to a separate page.  So, in the case of one of my customers when they want a news page that they can update and also a tips page that they can update – I set it up like this.  Create a category called news and a category called tips in the Admin area.

Here's how I set it up.  In the [User controls] folder is a control called PostList.ascx.  I added a property to this control called PageCategory.

Here's the code from the .aspx page which will set the PageCategory properly for the page:

 
<%@ Register Src="User controls/linksSide.ascx" TagName="linksSide" TagPrefix="uc2" %>
<%@ Register Src="User controls/PostList.ascx" TagName="PostList" TagPrefix="uc1" %>
<%@ Import namespace="BlogEngine.Core"%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="divError" runat="Server" />
<uc2:linksSide ID="LinksSide1" PageCategory="cleaningtips" runat="server" />
<uc1:PostList ID="PostList1" PageCategory="cleaningtips" runat="server" />
</asp:Content>

 Here's the code which implements the PageCategory property inside of PostList.ascx. 

Basically, it all comes down to making sure the only posts which display are those which  match the category.

  ( Linq would work great on this)


foreach (Category cat in Category.Categories)
{

string name = cat.Title;
if (name.Equals(PageCategory))
{

List<Post> visiblePosts = cat.Posts.FindAll(delegate(Post p) { return p.IsPublished; });
if (Posts == null || visiblePosts.Count == 0)
{
hlPrev.Visible = false;
hlNext.Visible = false;
return;
}
else
{
hlPrev.Visible = true;hlNext.Visible = true;
}

LoadAll(visiblePosts);
break;

}
}
 

Tags:

Comments

9/30/2009 1:41:07 AM #

Use BlogEngineNet as a Content Management System  , raised my curiosity. I have recently set off to develop using Silverlight but I am finding it is a big learning curve.  My earlier experience is with mysql, php, most linux based tools and flash. The challenge of using Silverlight to arrive at a satisfactory visual design that runs rapidly in all the major browsers, Internet Explorer, Firefox, Safari and Google Chrome can be a great head ache which is taking me several hours to solve.  Absorbing to read your thoughts and the comments in your website on Silverlight.  I find the tutorial sites and Microsofts Silverlight site are strict and address the same points, comments and dialog in web logs frequently references genuine ways to resolve issues that takes me through the learning curve more rapidly.  Thank you for the article, it has assisted in a small way to take me through the migration.

Blocked Drains United Kingdom

11/2/2009 2:25:47 AM #

Pingback from scriptsrss.com

Use BlogEngine.Net as a Content Management System Scripts Rss

scriptsrss.com

Comments are closed

 

RSS Feed FriendFeed