Video tutorials and Online Training
Unlimited Access
Video Tutorials
Video Available as Flash

Bookmark Us

Bookmark Website 
Bookmark Page 

User login

Recent comments

Navigation

Blogs

cck & taxonomy

Drupal provides two methods for adding structured data to a node.

The first is the out-of-the-box Taxonomy module. Taxonomy allows you to associate a vocabulary with a content type. When creating or editing the node, you are invited to choose a value for the vocabulary from its associated list of terms. In essence, you are associating a structured field with your node. The name of the field is the name of the vocabulary and the value is the selected term.

The second method is the CCK module. The terminology of CCK is less confusing. Using CCK you define fields and associate these with a content type. When creating or editing the node, you are invited to set values for the associated fields. There are a few obvious differences between Taxonomy and CCK

Dynamically execute all Drupal cron jobs for an entire server

You may have a lot of Drupal sites installed on the same server. Instead of creating a cron job for each individual site, you could write a script like this to loop through your sites and execute each cron job automatically. Here's the script I created using PHP, lynx, and find:

Creating a view to show all nodes that exist in user's Organic Groups using argument handling code in Drupal 6

I recently created a view to show all the nodes that exist in a user's organic groups. I originally created the same view in Drupal 5 by adding the filter "OG: Post in User Subbed Groups" is equal to "Currently Logged In User". Unfortunately, I could not find the equivalent filter in Drupal 6 Views, so I decided to use arguments. Argument handling code is structured a differently in Drupal 6:

1) add a new argument
2) for "Action to take if argument is not present" choose "Provide default argument"
3) for "Default argument type" choose "PHP Code"
4) for "PHP argument code" I entered:

return MYMODULE_views_group_nids();

It's a personal preference of mine to NOT insert code into my database, so I added the previously called function into a module. IMHO, code belongs in subversion so it can be versioned properly, not in a database. Here's my function definition:

 

CCK select option html entity issue

I recently created a CCK node that had a few select fields. For some of the allowed options, I used "<" and ">". For example:

lessThanZero|<0
zero|0
greaterThanZero|>0

It appears that the html entities were being escape too many times, because the select options contained:

&lt;
&gt;

When I viewed the source of my page, the actual HTML was:

&amp;lt;
&amp;gt;

Until this issue is resolved, I decided to add a piece of code to my module to correct the issue. The preprocess functionality of Drupal 6 allows you to modify data on its way to your theme, much like the _phptemplate_variables() function in Drupal 5.

 

Create an admin settings page for your module

Here's a code snippet to show you how to create an admin settings page for your module. In this example, I'll create a form that allows the user to enable/disable checkboxes for each node type. This might be useful if you wanted to modify the functionality of a node and allow the user to choose which nodes.

user warning: Got a packet bigger than "max_allowed_packet" bytes

I just the following error when loading a large cck node form:

user warning: Got a packet bigger than 'max_allowed_packet' bytes

You can resolve this error by adding a line to your /etc/my.cnf MySQL configuration:
[mysqld]
set-variable = max_allowed_packet=32M

Creating a multipage form using the Forms API

Recently I've been struggling with creating a multi-step CCK node form in Drupal 5. I was able to implement a solution that used a combination of form_alter and jQuery, but due to the amount of jQuery, it was too slow. I then attempted the same functionality in Drupal 6, but due to the number of changes in the Forms API, I decided to take a step back. Here's my first successful attempt at creating a multi-step form using a Drupal 6 module and the Forms API. The following code adds the ability to jump to any step of the form, save at any point, and dynamically creates steps based on the number of fieldsets. My next step will be transposing this code to work with a CCK node form.

Screenshot:

Videos Search