<body bgcolor=#000033"><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener("load", function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <iframe src="http://www.blogger.com/navbar.g?targetBlogID=4830160160028833890&amp;blogName=DanShope.com&amp;publishMode=PUBLISH_MODE_FTP&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;homepageUrl=http%3A%2F%2Fwww.danshope.com%2Fblog%2F&amp;blogLocale=en_US&amp;searchRoot=http%3A%2F%2Fblogsearch.google.com%2F" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe" title="Blogger Navigation and Search"></iframe> <div></div>

PHP and MySQL Content Management System

The backend for DanShope.com is a custom grown content management system (CMS) I wrote in PHP and SQL. A CMS is designed to allow simple yet powerful management of content across a site - blogging software is a common CMS a lot of people are familar with. A good CMS will abstract the physical content or meat of a page away from the HTML source code, so you can use a WYSIWYG editor or just a plain ole text box for input. The CMS then styles and produces your formatted page when someone wants to look at it.

MySQL and PHP are best friends and work really well together. MySQL is very fast and stable and allows for quick data manipulation across large datasets. A database is basically like a large spreadsheet that you can search, but it has some reallly neat features that make it irreplaceable. The power of SQL (structured query language) comes out in a well structured relational database.

A good database will be normalized, or reduce the amount of repeated data. For example, on DanShope.com the database is used to store a member id for each registered user. Each user can have multiple projects, each of which can have multiple pages. Thus we have a database table USERS and some tables PROJECTS and PAGES. When I look at any given page, I want to be able to tell what project it belongs to, and who that project belongs to. Through the magic of SQL I can construct my database such that this data doesn't need to be repeated in each page. Instead of PAGES having columns like (Page title, Author Name, Author ID, Email Address, Location, Website, Member Login, Page Content, Page Number, Project Title, Project Start Date, Project Category) I can just have the data unique to that page.

We get something that looks more like (Page ID, Page Title, Page Content, Project ID) and everything else is inferred by the relationship through project ID. Note that we don't even store the member information at all, since it can be found through the PROJECTS table (Project ID, Title, Start Date, Category, Member ID). This type of relationship really is magical because it allows intelligent and accessible data in a very compact form.

So, once we have a database, how do we get content in and out of it? That's where PHP comes in handy. PHP is great for online content creation because it interfaces so beautifully with HTML and other web based technologies. You can use a lot of languages with a SQL database, but for online communication PHP is the de-facto standard. There are PHP scripts running in the background that call up and create a page whenever you click on a link, and insert data when I use the adminstrative pages. There's some neat stuff like page caching and tagging behind the scenes that took a while to implement but were totally worthwhile.

I'll talk in a later post in more detail about how all of this works and where to find good resources online to roll your own CMS! If you've ever tried to manage a site without one it's really quite exciting and a big relief to let the computer do the heavy lifting. Never again will I try to manage a 100+ page website completely by hand!

Labels: , , ,

blog comments powered by Disqus

« Home | Next »
| Next »
| Next »
| Next »
| Next »
Subscribe to RSS Feed
Subscribe to DanShope.com
Who writes This Stuff?
Daniel Shope is the site owner and moderator of DanShope.com, a portal dedicated to robotics and engineering. Dan is currently a student at Carnegie Mellon University and is pursuing dual degrees in Mechanical and Biomedical engineering.

View Daniel Shope's profile on LinkedIn
Advertisements