Theming a CCK field using a template file
While it is a quick and easy operation to manipulate markup using hook_nodeapi()
, as our requirements become more complex, we inevitably need to resort to locating our customizations within a template file. Theming CCK fields using template files is just about the same as theming anything else in Drupal, albeit with a couple of caveats.
In this recipe, we will look at modifying the output of the Phone field in the company
node type to use an unordered list when there are multiple items present.
Getting ready
We will be using the myzen theme created earlier in this book to hold our theme customizations. Following the recommendations outlined in earlier chapters, we will also be making use of the Devel and Theme developer modules to assist in identifying the theme functions and templates to override. It is assumed that these modules are installed and enabled.
To get an idea of the work at hand, navigate to a sample company node and view the markup of a...