Data to quickly create a Country Field with CCK
Sometimes you just need a quick solution, using the built in functionality of modules you are already using without adding extra modules to your site. For example, you might want to add a country field to a node using CCK without the overhead of a complex module like Location.
Here's an easy way, just use a standard text field, with a "Select List" widget. You then just need the data to create the options. Here's the data you need, ready to copy and paste into the options for the CCK widget.
CCK Fields in Core for Drupal 7
I mentioned previously that I'm keeping an eye on the new features coming up in Drupal 7, and there's a biggie confirmed over at d.o with the inclusion of CCK fields in Drupal core. The delay in release of CCK and Views for Drupal 6 has been the main reason for the slow migration to Drupal 6 from Drupal 5, and moving key functionality like this into core can only be a good thing.
Node reference create for Drupal 6 CCK Node reference field
I posted about this in relation to Drupal 5 here. Now it's time to do this with Drupal 6...
Let's recap: Node reference field allows you to add a link from one content item to another. You add the reference to another existing node when you create a node with a nodereference field. The node being referenced must exist in order for this to work.
Drupal Installation Profile Woes
Most of my work to date has been Drupal 5, but a new project I am involved in has required the switch to Drupal 6. On the whole I couldn't be happier - D6 is really nice in so many areas, and the switch has been pretty painless. Except - I'm now looking at Drupal installation profiles.
A couple of gotchas that I wasn't expecting...
Programmatically Creating Drupal Nodes
The Drupal for Developers event was great fun this week. I did a 15 min presentation on Programmatically Creating Drupal Nodes. The slides from this presentation will be going up on the Drupal UK site in the near future, but you can get a preview of the presentation below.
Presentation for Drupal Developers Meeting
I will be speaking at the next Drupal UK event, which is being held at The Economist offices in London next Wednesday, 30th July.
My presentation is going to be about programmatically creating content (nodes) including CCK fields, attachments, and images. I will be presenting a case study from recent development that automatically creates content from iTunes Producer packages.
Places are limited but you can find more information and signup here:
http://drupal.org.uk/event/drupal-developers/04-jul-2008
Also, check out the other upcoming Drupal UK events, I will also be presenting at the Enterprise event.
Node Reference Autocomplete with Auto-create Drupal node content from Wikipedia
Here's a few bits of code from today's Drupal wranglings that solves a tricky UX problem with Drupal and CCK Node Reference fields.
Ever wanted to deal with the case that a user might want to reference a node that doesn't exist yet? Well I've played around with a couple of modules (Add n Reference and Add Node), but they didn't offer the clean user experience I needed. Here's an example use-case:
Image Resizing with CCK, Imagefields, Imagecache and PHPTemplate
If you have a CCK content type with an image field you get display options that allow you to change the image size on teasers and full node views. First you set up your image presets using the imagecache settings. I usually let users upload at any size, and deal with the resizing as required. Here's how to ensure you get best results from imagecache, and how to embed imagefield images into your PHPtemplates using the theme functions provided by imagecache:
Programmatically Creating CCK Nodes and Adding Images with Imagefield
There's a useful post on civicactions that explains how to create nodes in your Drupal site programmatically. I'm using this technique to create an import script for processing bulk quantities of XML files.
There's a facet to the create node process, in that I couldn't get it to import images using the $values[] array.
I found that I could create all the CCK fields by assigning them fields in the $value[] array, but for imagefield values I had to instantiate them in the $node object instead.






