This tutorial will teach you how to create module-like functionality adding a To Do list functionality using the default installation for Drupal 6.6. The whole process takes less than 15 minutes, and now new modules have to be installed.
1. Enable PHP Filter Go to Administer-> Site Building -> Modules. Check the box for PHP Filter, and click Save Configuration.
2. Create a "Project" vocabulary Go to Adminster -> Content Management -> Taxonomy. Click on Add Vocabulary, enter a name. Under Content type, click on Story. Click Save.
3. Add "To Do" and "Done" terms to the Project vocabulary Go Go to Adminster -> Content Management -> Taxonomy. Under the list of vocabularies, find Project, and clik on its "Add term" link. Enter under Term Name "To Do" and click Save. Repeat steps to add "Done".
4. Create a new To Do Block Go to Administer -> Site Building -> Blocks -> Add Block. Name it "To Do". Under Input Format, click on PHP code. Copy and paste the code below
<?
// comma separated lists of terms tid to display nodes
$term_name = "To Do";
$terms = "SELECT tid from {term_data} where name LIKE '" . $term_name . "'";
// the number of nodes to show
$count = 10;
$sql = "SELECT n.title, n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid in ($terms) AND n.status=1 ORDER BY n.created DESC";
$result = db_query_range(db_rewrite_sql($sql), 0, $count);
if ($result) {
return node_title_list($result);
}
return t('No nodes available.');
?>Click on Save Block.
5. Enable Block Go to Administer -> Site Building -> Blocks. Find the block. Then select a position from the drop down menu called "Region."
You are done.
And now for the longer explanation.
Drupal is web lego blocks &175; . This means that you should be able to get up and running very quickly with it, snapping together existing code that already is there.
In many cases, a functionality is the same as a module in Drupal. And when we need new functionality, we look for a module. That was what I was doing when I wanted to have a To Do list functionality in my site.
As I was looking for it, I was thinking what would it take to write that module myself. Thinking through what kind of functionality I wanted, I realized that I could do this with the default installation by using Taxonomy Vocabulary and terms, a custom block, and the default story content type.
So this is how the To Do functionality works: I can enter a task and description of it with a story node. All what I have to do is to give it a "To Do" tag under the Project vocabulary. When the task is done, then I change the tag to "Done". Simple!
I also get a page with a list of all the tasks that I have in my to-do list and my done list automatically through taxonomy.
I wanted to have a block that would remind me what was in my to-do list. For that, I used a slightly modified version of the block php snippet found here:
http://drupal.org/node/135344
My version is easier to read, but the version in the link should be a bit faster. (If you wonder about it, just hover over the term that you want to link, The number at the end of the link is the term id).
And obviously, you can adapt this example for similar kind of content. :)