danielhordern.com
Sample News
html displayflash display
News System - why?

From time to time I stumble across (and notice) web sites that display a list of current news articles / diary entries (or blogs ). Usually, for a brief moment, I consider the possibility of displaying such content on my personal web site, but end up discarding the concept as "too maintenance heavy" ( I don´t enjoy repetitively html ). Recently a friend (mikegaal.com) mentioned he had a client with a requirement for self managed news articles, and was wondering if I had done this before. Now was as good a time as any! It was time to throw together a solution. The top of this page shows results as a work-in-progress.

Features required

  • Display Title, Author, Date posted, Text for each article, listing N articles per page, sorted by date, per page.
  • Display links at bottom of page for "prev page" and "next page" automatically as required.
  • Online data maintenance (sites will probably password protect these areas)
  • Support multiple tables of articles ( and / or databases ) per site.

Implementation requirements

  • Database driven - assume ms-access, although it wouldn´t take much to move this to MySQL etc
  • 100 % ASP & JavaScript (because that´s what I do on this site!)
  • Ensure it is trivial to drop-in to any (ASP) site (read - no global vars, no constants, no session-vars)
  • Allow site customisation of "look" - use style sheets.

 

Here´s how did I did it

All functionality resides in a single ASP file ( note: two helper asp files, and two style sheets are also required ). Each public function generates the required html, either displaying articles, displaying forms etc. This approach makes it incredibly simple to add news to an existing site, without altering much existing html / ASP.

Heres how well this approach works - To display news articles on this page a single line was added (I´m assuming IE for IFRAME - substitute if not IE)

<iframe src="display_news.asp"width="400" height="300" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0"></iframe>

display_news.asp: (supplied by site) has 4 things to do. Include the main functionality file (news_functions.asp), include the site implementation of the style sheet for news display (news.css), nominate the database location and table name, and finally - call a single ASP function to generate the news html - below is my sites implementation

<%@LANGUAGE="JavaScript" %>
<!-- #include file="news_functions.asp" -->

<HTML>
<head>
<link rel="StyleSheet" HREF="news.css" type="text/css">
<title>News</title>
</head>
<body>
<div class="maincontent">

<%
var database = "database_name.mdb";
var table = "table_name";

news_WriteNewsArticles( database, table, StartDate, PageSize );
%>

</div>
</body>
</HTML>


Editing of the database table, editing, deleting and adding records (ie. Admin) are implemented in the same manner. You provide the ASP file that defines the page look, include the same information nominated above, and call a single ASP function to generate the html required to edit the table, and individual records ( rather than news.css, a separate "news_edit.css" is supplied )


Next.... Flash ? What da!