Programmatic CCK Content Types – The Patch

UPDATE 02/12/2009: this patch is out of the date, please refer to the Alternate Content Copy module now.

A few days ago I wrote a HowTo for creating CCK Content Types programmatically, including their update. Unfortunately, I must have missed something in my tests, so I found out later on that the updates won’t work properly.

This is due to the behaviour of the CCK import procedure, that skips already existing fields, so these don’t get updated. Plus, it also keeps fields no longer available in the updated content type definition, i.e. you cannot drop fields either.

I submitted a patch to the content_copy module, which turned up to be kind of a duplicate. Now the discussion is going on here, and my latest comment (including my patch) is here.

At the moment, Markus does not seem keen to include this patch, or any similar one, at all. We’ll see what happens.

In the meantime, I am using an alternative approach, because I don’t like to have patched modules in my installations. Basically I wrote a module called custom_content_copy that implements an alternative submit handler for the Content Copy import form. This way, you just need to install this module alongside of the content_copy module provided by CCK.

If you want, you can download this module here:

Custom Content Copy. Please refer to the Alternate Content Copy module now.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • LinkedIn
  • Ping.fm
  • StumbleUpon
  • Twitter
  • Wikio

Programmatic CCK Content Types

Update 28/11/2009: you need this patch to make this working 100%.

The fundament of Drupal is the node entity. In drupal (almost) everything is a node, which is the most elementary piece of content available, that can be “extended” to create new node types, also known as content types.

When you create new Drupal content types in the “classical” way, you do that by creating a new module. This way a content type is portable across different Drupal installations, just by copying and enabling the module in a new CMS instance.

Originally this was the only way to create content types. Then, CCK was created and it changed the life of many people, especially of those who use Drupal just as CMS. However, these people tend to create content types by means of the UI provided by CCK and to store them into the DB. This way a content type is not portable. Plus, it is not really friendly with complex development scenarios where Drupal is heavily used as framework and the code must be deployed across multiples environments.

Fortunately, we can achieve the same flexibility of the classical method, and more, taking advantage of all the CCK features, including the built-in integration with Views. Let’s see how. All you need is the latest versions of Drupal 6, CCK (and, optionally, Views).

Read more →

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • LinkedIn
  • Ping.fm
  • StumbleUpon
  • Twitter
  • Wikio

Spelling correction with Soundex

Google Spelling Correction

A few days ago Ian Barber wrote an article about the automated spelling correction.

Today I had the time to read it. Good quality and great presentation as always. However, the first thing I noticed is that the solution presented by Ian was not making use of the Soundex algorithm at all, which seemed slightly strange to me according to my experience. So, I have quickly refined that solution using the standard soundex() PHP function.

Read more →

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • LinkedIn
  • Ping.fm
  • StumbleUpon
  • Twitter
  • Wikio
 

About me

Vincenzo Russo
Hello, this is Vincenzo, I am a computer scientist, a Web engineer, a passionate and enthusiastic developer, an HCI passionate, and, sometimes, a Machine learning researcher. I currently hold a permanent position as Technical Lead Engineer at Ibuildings, in London. Learn more about me.