cck

Posted by: 
Dominique De Cooman

Here is an example on how to obscure email addresse (or other tekst) using http://drupal.org/project/signwriter in a formatter. You can use it on the cck field overview as a formatter (or in display suite).

<?php
//cck formatters
/**
 * Implementation of hook_field_formatter_info(),.
 */
function your_module_field_formatter_info() {
  return array(
    
'text_as_image' => array(?>

Gettting the labels for a cck field

Dont print labels hardcoded in your templates, they are configurable by interface.

http://thedrupalblog.com/getting-cck-field-labels

Think twice when defining a new content type

Think twice when defining a new content type

http://drupal.org/project/conditional_fields

This project allows you to have conditional fields.
Example : we have a content type bus and tram with only two fields difference. The type gearbox for a bus and the type of controller for a tram. All the 10 other fields are just the same. You dont want a new content type for that. You need a conditional field.
So create content type vehicle and have vehicle type field, now set the other fields like gearbox - controller conditional to this one. I also works with fieldsets.

Posted by: 
Dominique De Cooman

A cck fieldgroup can be rendered alone. We had some quicktabs we wanted to fill with our field groups. So we've builded a block for each field group to put in the quicktabs. Here is an example of one block where we called a single fieldgroup and rendered it.

Posted by: 
Dominique De Cooman

How to add another formatter to a cck field? A cck formatter is basically a theming function where the value of field is ran through. Formatters are available at "admin/content/node-type/[your node type]/display" in the cck interface.

Posted by: 
Dominique De Cooman

How to load only the content fields of a node to avoid a full node load?

Sometimes in scripts you need information stored in cck fields but you dont want to do full node loads neither do you want to query the table directly because setting a field from single to multiple value would make the table location of that field change.

Drupal module Fancy Multiselect

This drupal module allows the http://drupal.org/project/jquery_multiselect module (which include the jquery ui multiselect plugin) to be included as a cck widget.

The complete tarball including (jquery_update, jquery_ui, jquery ui multiselect 1.7.3, jquery_multiselect and plugin, fancy_multiselect) jq_multi.rar

Drupal.org project page : http://drupal.org/project/fancy_multiselect
Drupalmodules.com : http://drupalmodules.com/module/fancymultiselect

Posted by: 
Dominique De Cooman

The standard way of altering form elements and setting them disabled does not work with cck fields.

<?php
function my_module_form_alter(&$form, &$form_state$form_id) {
  
$form['my_element']['#disabled'] = true
}
?>

The FAPI process handler of the CCK field won't transfer the #disabled attribute to its children elements.
You'll need this snippet to make it work.
<?php
/**?>

Subscribe to cck