2 posts
on 8/12/2004
ColdFusion and the CMX Blog
Posted Thursday, August 12, 2004 7:30:49 AM by Tom Muck

Today is the debut of CMXtraneous, the CMX blog. Each Community MX member has an area where he or she can wax poetic on all topics. Because each member has different areas of expertise, different views, and varying interests, there will be a wide variety of topics. My own posts will most likely be related to ColdFusion, SQL Server, and Dreamweaver, with a little commentary here and there.
As with most of the site, the blog is a custom application written with CFML. We chose not to use one of the many blog packages out there so that the blog could be integrated into the site, rather than tacked on as an afterthought.
The basis of the blog was covered in a 3 part series of articles that is available from Community MX:
Creating a Simple Blog Part 1
Creating a Simple Blog Part 2
Creating a Simple Blog Part 3
The articles show how to create basic database tables, administrative pages, and blog pages using ColdFusion, PHP, or ASP. The Community MX blog, however, goes much further in functionality than the basic articles showed. I took the simple blog created in the series and rewrote it from scratch to use CFCs and SQL Server stored procedures. Future articles in the series will show some of the other aspects of blogs that were put to use in the Community MX blog, like the modules used in the sidebars, categorized RSS feeds, and the multiple blog functionality. One of the advantages of working with CFCs is that you can simplify every aspect of your application. For example, when you have to query a database to retrieve a list of posts, it's much easier to write this:
myPosts = myBlog.getPosts()
than this:
<cfquery name="myPosts" datasource="myDSN">
SELECT i.blog_item_id, i.blog_item, i.blog_item_datetime, i.blog_item_title, bc.category_name
, COUNT(c.comment_id) AS TheCommentCount FROM blog_items i
LEFT OUTER JOIN blog_comments c
ON c.blog_item_id = i.blog_item_id
INNER JOIN blog_categories bc
ON i.blog_category = bc.category_id
GROUP BY i.blog_item_id, i.blog_item_datetime, i.blog_item, i.blog_item_title,
bc.category_name
ORDER BY i.blog_item_datetime DESC
</cfquery>
Yes, the function in the CFC will contain the necessary code, but the advantage here is that you can now use myBlog.getPosts() from other places as well. Also, if you remove the query and convert it to a stored procedure within the CFC, your ColdFusion page does not change. If you decide that getPosts() will retrieve the data from an XML file rather than a database, your ColdFusion page does not change. Here's one more added bonus: the CFC function can also be called from Flash unchanged. Another bonus? The CFC function can become a web service that can be utilized from any server language that can consume a web service.
Yes, CFCs are the best thing to happen to ColdFusion since the introduction of the ColdFusion tag. Rather than being an advanced topic in the ColdFusion classes, it should be one of the first things that a budding CF developer is taught. Of course, there are different levels of CFC use as well. You can simply create a CFC as a file that is full of functions, or you can use the more advanced object-oriented approach with design patterns. The bottom line is that the functionality of the ColdFusion application should be put into CFCs.
The articles showed database access using queries. This approach works with any application server and any database. However, if you have SQL Server or another enterprise-level application server at your disposal, it just doesn't make sense to write queries. This is especially true when you are building a web application. When you put together an application like a blog or an e-store or even a guestbook, you are basically putting your database on the web. With all the web terrorists out there (the hackers), this is inviting disaster. If you value your data, use stored procedures and lock down your database. It should be a goal of anyone working with SQL Server to use stored procedures for everything they do, from the simplest SELECT * FROM MyTable to a complex multi-table insert. Of course, using stored procs is not enough -- you also have to validate any incoming url and form variables so that they do not get passed to the database directly.
Category tags: Dreamweaver, ColdFusion, Blogs and Blogging
Posted by Tom Muck
Add comment |
View comments (1) |
Permalink
|
Trackbacks (0)
|
Digg This
Creating Your Dreamweaver
Posted Thursday, August 12, 2004 7:11:53 AM by jojo

When you first install Dreamweaver it is very easy to get caught in "the sweetie shop" with regard to extensions, we all love them! They ease our workflow and allow us to implement functionality in a few clicks, often saving a great deal of time on repetitive tasks. After a while we see the error of our ways, we look at what we grabbed from the sweetie shop and realise most we never use at all. The weeding out begins!
I think it would be kind of cool to share what remains in our Extension Managers after the weeding out has taken place. We could share information on the extensions that we REALLY find useful here, we could point other Dreamweaver users to where they can get them and explain to them why we think they are so useful.
I'll start the ball rolling with some of my favourites, in no particular order:
- Tom Muck's dynamic SQL Search and his Recordset navigation suite
- Danilo's CMX create include
- Massimo's check image upload
The dynamic SQL search extension by Tom Muck is just such a huge time saver, and it is so easy to implement. From selecting the searchable columns to setting the high-lighting of the search words in the results. The time saved in producing a really professional search facility is immeasurable!
Another one of Tom's extensions is the recordset navigation suite, very nice. You can check this one out here, easier to see it in action than try to explain. Incidentally this site also uses the dynamic SQL Search extension, try searching for mice from the banner to see the high-lighting in the search results. This site is still under going some work, so one or two little issues around.
Danilo's CMX create include, just makes the whole include process a breeze. Select your code and create the include from the context menu, job done!
Massimo's Check Image Upload, the perfect solution for a multitude of situations. Catches the width and height on upload for inserting into the database, makes image upload facilities in a CMS a breeze. PC browsers only on this one though.
The three I have mentioned are all to do with server-side technologies, feel free to point out extensions of whatever category you feel helps you most.
What do you have in your box of tricks?
Category tags: Dreamweaver
Posted by jojo
Add comment |
View comments (5) |
Permalink
|
Trackbacks (0)
|
Digg This
2 posts
on 8/12/2004


Blog RSS feed












