1 thing we can do with the Homepage in Subtext.. Change it from the norm

It’s been a while since I wrote my 1st article about subtext skins and unfortunately I have to start re-writing 2 and 3 as my laptop drive decided to go Pete Tong on me.  Learn from events like this so now I use BT Vault for my main files and anything I buy from iTunes is backed up on another 2 hard drives….  I am off work in a couple of weeks so my plan is to catch up with my subtext skin articles and re-write my current skin 🙂

I have been looking at converting some of the themes out there over to subtext and while converting one I remembered an email that Phil Haack sent in relation to the homepage.ascx control and the viewpost.ascx control.  Most of the themes currently available don’t take advantage of these controls as most people want a constant look and feel throughout their site so just use the pagetemplate.ascx.

Homepage Control.

Ok so I think lets start a fresh lets remove the DayCollection control and add in some general text.  I add in a header 2 and a paragraph of text, refresh my homepage and “Server Error – object not set to an instance of an object”.  I add back the DayCollection control set the “visible” attribute to false and we have a winner….


Now I am thinking why is the page breaking when I remove the DayCollection control?  The reason is :

Within the HomePage onLoad event

HomePageDays.Days = Entries.GetHomePageEntries(Config.CurrentBlog.ItemCount);

The application falls over due to the DayCollection Control “Daylist” not being on the page, possible bug?  In this case we don’t want to show all our posts on the page like normal, so we set the display of the control to false.

Ok so what else can we do in the Homepage control?   We could make it a general introduction page, remove the recent posts from the side bar and put them in the central area…

How do we do this?  It’s very straight forward.  Firstly I set the recent posts usercontrol within the pagetemplate.ascx to false and then I changed the Homepage.ascx control to:

   1:  <%@ Control Language="C#" EnableTheming="false"  AutoEventWireup="false" Inherits="Subtext.Web.UI.Controls.HomePage" %>
   2:  <%@ Register TagPrefix="uc1" TagName="DayCollection" Src="DayCollection.ascx" %>
   3:  <%@ Register TagPrefix="uc1" TagName="RecentPosts" Src="RecentPosts.ascx" %>
   4:  <uc1:DayCollection id="HomePageDays" runat="server" visible="false"></uc1:DayCollection>
   5:  <h2>Welcome to my website</h2>
   6:  <p>I have been trying to work out how to get the homepage.ascx control to work so that my homepage
looks different from other pages</p>
   7:  <img src="imagesdirectory/simon.jpg" alt="simon" />
   8:  <uc1:RecentPosts id="RecentPosts1" runat="server" />

The outcome….


With this change some css modifications would be needed for example the un-ordered list isn’t formatted as it should be(orange square).  We could keep playing about with the homepage control, maybe add in a tag control.  It’s there to be played about with so why not….

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.