Wednesday, November 4, 2009

Getting started with Drupal 6

Now that I have made a few sites with Drupal 6, it is time to review my experiences and create a "getting started with Drupal" guide out of it.

My assumption is that you want to use Drupal as a step up from either a basic blog (like Wordpress) or a basic CMS (like Joomla). I assume there will be 3 types of people using the website: you, the administrator and the users. A further assumption is that you don't want to touch code, but that you do want to create functionality that is different than what comes out of the box. The administrator will be someone responsible for the content on the website, possibly the owner of the site. The users are visitors to the site.


Towards the functionality of the website, I assume you have a few basic needs:
  • a menu with a few static pages, like "about us" "contact" etc.
  • a photo section that allows the administator to create albums and easily batch upload photo's
  • a "news" section that is essentially a blog, used by the administrator to update the users and of which the last post is shown on the homepage
  • a "special notice" in the sidebar that remains visible on every page
  • a forum where users can discuss
Most of this comes with Drupal out-of-the-box. But there are some quircks:
  • photo's are not supported. And if you configure an image type, you still don't have an album solution or can't use the image in a blogpost or in a static web page
  • There is no richt text editor for content. So your articles will look rather dull
  • Sidebar content is supported, but giving an administrator access to this also opens up access to other things that he/she potentially can mess up
  • forums are included, but displayed in a threaded view. Most users will prefer a sequential list of messages (in Drupal terms: comments) attached to a forum topic.

Luckily, Drupal has a modular structure that allows you to add functionality with, you guessed it, modules. The modules that I use for my basic "getting started" website are:

advanced_help
cck
views
views_bonus_pack
filefield (latest DEV version)
imagefield
imagecache (only use GD2, don't use imagemagick)
image_api
transliteration

Do not forget to give the administrator the necessary access rights on these modules. Also, users will not be able to see the output of the modules if you don't give them "view" access.

The most difficult module to understand is the views/cck combination. Let me first explain how Drupal works.

Drupal maintains a database that consists of nodes. Nodes are bits of content that can be uniqely identified. They have a type, a way to display them, a way to enter them using a form and a way to classify them with taxonomies (think of it as tags or categories). Nodes are entered by authors and are taken through a publication workflow. An example of a node is an "about page". The type of this is "page". The author will most probably be the administrator and it will be published without the need to be reviewed. A blog comment is another example of a node. It might be created by an anonymous user and will need to be reviewed by an administrator before being published. Each node has a unique ID that can be used in a URL to access the view on that node.

What the cck module does is to create new node types. Suppose you want to create a node type "review", you might want to let the author of a new review provide fields for product name, product categorie, review summary, good points, bad points, a picture of the product and a picture of the packaging. You can construct such a node type with cck.
However, the standard way to view this node will be that Drupal will generate a page with all the fields beneath each other. This might not be what you want. You can use the "views" module to create a webpage that only displays some parameters, or to display a webpage that lists the titles and summaries of all reviews, so users can click on the title to read the full review.
Views is essentially a visual query-builder. Those of you familiar with SQL might recognise the SELECT, JOIN and WHERE clauses in the visual representation that views offers. I strongly advise you to go through a video walkthrough of views/cck before getting your hands dirty.

Once you're familiar with cck/views, I advise you to create your own "photo album" solution with it. I added a binary field "use as album cover" to my self-create photo content type.
In taxonomy, I created a new taxonomy called "photoalbums" and added terms for each album. (make sure that the field "term" is obligatory in your cck photo type). Of course, an administrator can always add more albums if he wants. He only needs to add a term to the taxonomy to create a new album.
I created a view "photoalbums" that lists all albums, shows the image that has the flag "use as album cover" and shows the description. Clicking on the album gives a preview of all images in the album. Clicking on the image gives a node view of the image itself.

Now there are a few things you can do to make your album even nicer:
  • the "teaser" and "full" imagecache presents that you choose for the image field in your cck photo type can be made a whole lot more exciting with Imagecache actions.
  • To have a nice Javascript album viewer, install the Lightbox2 module. It will automatically generate extra imagecache presets that you can use in your custom view
  • Make a new view to show as a sidebar block that holds the last 10 images uploaded. You can create a new imagecache preset for this.
  • Install Image FUpload to allow the administrator to upload a whole bunch of photo's in 1 click and to edit all of the captions in 1 operation, just like on Flickr.

Once you have this nailed down, you are on your way to become a Drupal expert. One thing you can do as a quick win is to change the options of the built in comments. You can set comments for all content types to "flat" view. Disable the title input field and the preview button with nodeformsettings. You can alos make the comment field a bit smaller and disable the explanation text below the box.
Another nice extension to a basic site is Side Content, which allows you to add an extra textfield to a node type (e.g. Page). This text will be displayed in a block in the sidebar when the user browses to that particular page. You can set the side content block to only be visible on specific pages if you want to.

When your users are capable enough, you can install FCKEditor to give them WYSIWYG editing capablities. Make sure you follow the readme.txt file on this one, because there is more to do then just enable the module. I also prefer to only enable FCKEditor on specific pages (like create/edit blog/page content). Otherwise, users will start using HTML tags in forums and content titles, which is not the idea.
To take it one step firther you can install the IMCE module on FCKEditor to let users upload and insert a picture in their news article all in 1 operation. This is much more user friendly then asking the user to go through the 2-step process of first uploading a photo to either the Drupal site or a site like Flickr and then entering the URL of the image in FCK.
A last tip: If you want your administrator to be able to change a static block of side content, but you don't want to give them website construction privileges, you can create a view that displays the content of a specific page (eg. title=sideblock content). You place the block generated by views in the sidebar and when the user wants to change the text, they just have to edit the specific page.

Taking this approach is proving to be really flexible. I don't have much time to do websites, but having established a good base I would like to take on a bigger project like creating a community site with delegates responsibilities and group membership. It's fun to create websites with Drupal!

No comments:

Post a Comment