In an earlier article I described how we can create a drupal block to display a twitter profile widget. This earlier method would use PHP in the block to evaluate the node each time and check if a twitter account existed. It works great but there are other alternatives I wanted to explore.
Yesterday I started using the computed field module. This is a CCK add-on module that executes PHP code during a node insert/update and (optionally) stores that value in the database. I say optionally because I believe you can also set it to evaluate PHP on the fly, however for something like a twitter widget we don't need to do this dynamically. Once the widget information is stored in the database we only need to display it.
So the objective here is to use the computed field to check if the node contains a twitter account. If it does then we simply compute the widget code and save it. If not, we leave it blank. So let's get started.