Build on the Drupal Database
Many people use Drupal to build websites -- and with great success. But deep inside Drupal is an SQL database (MySQL or Postgres, and in Drupal 7, SQLite). In addition to storing content in the database using the Drupal core and contributed modules, you can use CCK and Views to build a collaborative database-driven app on that same database.
Hour 23, "Using View Arguments and Modifying Built-in Pages" provides a step-by-step (eleven in all) recipe for building a project tracking system. That structure works for any two-level system that needs to be shared. Examples are:
- projects containing phases (the example from Hour 23)
- cost centers containing budget lines
- objectives and goals containing specific steps
- ...and many others
This is a variation of the project tracking system design in the book.
The point is to think about Drupal as a front-end to a flexible database (which is what it is) and not just a repository of web content that is delivered on demand. What this means is that you have an online collaborative system that can partake of all of Drupal's security. Yes, you can put your draft budget online for your workgroup to develop if you set up roles and permissions to keep it secure.
You need two content types:
- You need a content type for the container--the project, the goal or objective, the budget area, or the cost center.
- You need another content type for the details-- the project phases, the goal/objective steps, or the budget area's budget lines.
Although you don't have to think in database terms, you will be using Drupal to construct a one-to-many relationship between a container and its details. You probably will have many containers, each with its own details.
Here are the steps to build the database part:
- Create the container content type. You can use the Drupal defaults and many not need to add anything. You already have a title and body to describe the container. You may want to add CCK fields to further identify the container (a department ID, a supervisor, the project plan containing the goal or objective, etc.), but you can come back. Name the container whatever you want.
- Create the detail content type.
- In the detail content type, you need to create a CCK field that is a node reference to a container content type. As you create it, you will be prompted to use check boxes to indicate what content types can be used. Check only the content type you created in #1 (your container).
- Select how you will show the candidate content type nodes--selection list, check boxes, type-ahead, and you're done.
To build the view part:
- Use the Views module to create a view. The view is based on nodes (that's the first choice).
- In the View interface (see Hour 14: "Working with Views") use at least the following:
- Filters: published and node type = the type you created in #1 above
- Fields: include the node reference field you added in #3 above but use the Exclude from Display option and set the format to be a link to the node; add the nodeTitle field. Remember the node in question is the note you are filtering on (the detail content type).
- Style: HTML list (you can experiment later, but this works for a start)
- Style Options (gear icon to right): Grouping Field--set to the node reference field you added in #3 above
Assuming you have entered some data, you should see a display in the preview. Add a Page display and path to be able to address it. Note that you'll need at least two container content type nodes with at least one detail content type node for each one to see the proper effect.






