Content Management Systems (CMS)
From CSE330 Wiki
Contents |
[edit] Motivation
Almost all websites on the internet provide some kind of content that is to be presented to the user, preferably in a easy to browse fashion. There are many standard features in most of the websites we see today, such a user management, user comments on pages, e-mail notifications, etc that we take for granted. Implementing all these from scratch is like reinventing the wheel. Besides, we probably will not do a perfect job in terms of efficiency and security.
For such reasons, using code written by others makes sense. Content management systems provide a structured way to handle the work a general purpose website needs.
Drupal is such a content management system. It already provides a lot of functionality so that it is very easy to get a simple content-based website up and running in hours. It is also easy to extend Drupal's functionality and appearance using modules and themes.
For usage and other details, please visit Drupal.
[edit] Installation
Installing Drupal is very easy. Getting started with Drupal 5
When you extract drupal-5.3.tar.gz, note that there is the .htaccess file in it that makes some adjustments to Apache settings that are necessary for Drupal. The fact that this file is hidden (starts with a dot, mv * will miss it) and that it overrides Apache settings deserves some caution here.
[edit] Folders and Moving .htaccess
Let's say I'm in /home/gazi/public_html that is accesible as http://example.com/~gazi and I extract drupal there like this:
tar -zxvf drupal-5.3.tar.gz
now I have a new directory /home/gazi/public_html/drupal-5.3 and I need to go to http://example.com/~gazi/drupal-5.3 for Drupal. I can optionally move it to a folder with a better name:
mv drupal-5.3 site
Now I can go to http://example.com/~gazi/site to use Drupal and it's fine.
If I want to get rid of the folder name, I need to move everything to my public_html directory.
mv drupal-5.3/* .
Note that this will not move the file drupal-5.3/.htaccess to public_html since it is a hidden file. Instead you need to do:
mv drupal-5.3/* . mv drupal-5.3/.* .
You can ignore the errors for "." and "..".
[edit] Making .htaccess Work
If you are using Debian as suggested in previous classes, you will most likely get an internal server error when you try to navigate to your Drupal directory with your browser. If you check the end of /var/log/apache2/error.log, you'll see that it complains about the .htaccess file. This is probably because your current Apache configuration restricts the use of .htaccess files. You need to give full support for .htaccess files using the line
AllowOverride All
Where this line goes in your apache configuration is dependant on your specific configuration. If Drupal is in your home directory like this http://example.com/~gazi, you would edit it in /etc/apache2/mods-enabled/userdir.conf. If it is in a directory in other folders, you would need to edit the corresponding file in /etc/apache2/sites-enabled. These files are probably symbolic links, so when you edit them the files that they are links for get edited.
[edit] Creating Modules For Drupal
Drupal uses hook functions to invoke modules. Please see Module developer's guide for a guide on writing drupal modules and Drupal 5 API for core hooks.
The sample code we used in class is a slightly modified version of http://api.drupal.org/api/file/developer/examples/node_example.module/5
[edit] Creating Themes For Drupal
Please see Theme developer's guide, especially PHPtemplate documentation.
[edit] Drupal debugger's survival kit
Your module and theme functions will be called by Drupal, from different places in code that will have different contexts. Most of the time you will want to see what is available in variables, what the current call stack is, who called this function and in what order your functions are being called. There are PHP debuggers out there that you can take a look at, but here is a quick and dirty way to see how your functions are running.
Here are a couple of functions for this purpose:
drupal_set_message($message) This is the function that Drupal displays messages to the user, such as "changes were saved" etc. This is better than simply printing out, because it is being displayed in a neat place in the page and messages reflect the order that the function was called with. Also, sometimes your calls in Drupal end up in a redirect to other pages rather than creating a page to the user. In such cases, your "echo" statements have no effect unless you run "die;" after them. On the other hand, this function caches the messages created in redirecting calls to be displayed in the resulting page.
print_r($object) This is a great way to display objects and arrays to see what they contain. Run die; after them if you suspect you don't see the output because of a redirect. The page source will have a nice indented display of your objects and arrays.
debug_print_backtrace() This function in PHP outputs the current call stack. You can use it to see what function calls led to your function being called, and displays all the function arguments in between.
There are a number of modules such as coder and trace that can be of assistance.
[edit] Troubleshooting
[edit] PHP GD Library
If you are getting an error about the PHP GD library in the Drupal status page of your Drupal installation, you need to install the php5-gd library and restart apache:
apt-get install php5-gd /etc/init.d/apache2 restart
[edit] Teams for this module
Team 0: Gurnish Sahni, Scott Zachary Bressler. Please use zoo.cse.wustl.edu
Team 1: Lauren Miranda Jackson, Alan Jonathan Lundeen. Please use zoo.cse.wustl.edu
Team 2: Timothy Felix Trinidad, Douglas James Hyde. Please use zoo.cse.wustl.edu
Team 3: Weston Joseph Haught, Simon Tam. Please use zoo.cse.wustl.edu
Team 4: Adam Glenn Berger, Jeffery Tyrone Nelson. Please use zoo.cse.wustl.edu
Team 5: David Cassey Schainker, Micah Scott Herstand. Please use zoo.cse.wustl.edu
Team 6: Justin Alante McClain, Richard Zack Speyer. Please use zoo.cse.wustl.edu
Team 7: Daniel Everett Harter, Jeremy Neil Friedman. Please use oz.cse.wustl.edu
Team 8: Ryan Allen Johns, Jeremy Wayne Williams. Please use oz.cse.wustl.edu
Team 9: Mark Avram Lilien, Katherine T. Maschmeyer. Please use oz.cse.wustl.edu
Team 10: Daniel Edward Brewster, Mamta Jaikumar Datwani. Please use oz.cse.wustl.edu
Team 11: Thomas Jerry Moore, Helena Marie Wotring. Please use oz.cse.wustl.edu
Team 12: Aaron Edward Jacobs, Zachary Robert Dwiel. Please use oz.cse.wustl.edu
Team 13: James Leslie Grady, Garrett F Eardley, David Kaminsky. Please use oz.cse.wustl.edu
Team 14: Steven D Broner. Please use oz.cse.wustl.edu
Note that team 13 has three students and team 14 has one.

