Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: How to Create CCK-Field

Submitted by on August 5, 2010 – 7:39 amNo Comment

You need to create CCK-field. For example you may need to create CCK-field from hook_update_N.

Solution:

Unlike other CCK versions, fields manipulating becomes easier in CCK version for Drupal 6.

  • You need to create a field with the help of CCK user interface first.
  • Then you should use var_export() PHP-function, to get a dump of node field in the form of array.

    var_export(content_fields(‘field_ИМЯ_ПОЛЯ’, ‘ТИП_КОНТЕНТА’));

    See API: http://drupalcontrib.org/api/function/content_fields

Yyou will get a large array. You can copy your code there and use it in the following way:

$field = array (
‘field_name’ => ‘field_translator_note’,
‘type_name’ => ‘feature’,
‘display_settings’ =>
array (
4 =>
array (
‘format’ => ‘hidden’,
),
2 =>
array (
‘format’ => ‘hidden’,
),
3 =>
array (
‘format’ => ‘hidden’,
),
‘label’ =>
array (
‘format’ => ‘hidden’,
),
‘teaser’ =>
array (
‘format’ => ‘hidden’,
),
‘full’ =>
array (
‘format’ => ‘hidden’,
),
),
‘widget_active’ => ‘1’,
‘type’ => ‘text’,
‘required’ => ‘0’,
‘multiple’ => ‘0’,
‘db_storage’ => ‘0’,
‘module’ => ‘text’,
‘active’ => ‘1’,
‘columns’ =>
array (
‘value’ =>
array (
‘type’ => ‘text’,
‘size’ => ‘big’,
‘not null’ => false,
‘sortable’ => true,
),
),
‘text_processing’ => ‘0’,
‘max_length’ => ”,
‘allowed_values’ => ”,
‘allowed_values_php’ => ”,
‘widget’ =>
array (
‘rows’ => ”,
‘default_value’ =>
array (
0 =>
array (
‘value’ => ”,
),
),
‘default_value_php’ => NULL,
‘label’ => ‘Translator\’s note’,
‘weight’ => NULL,
‘description’ => ”,
‘type’ => ‘text_textarea’,
‘module’ => ‘text’,
),
);
// Load CCK –file where content_field_instance_create() function is defined
module_load_include(‘inc’, ‘content’, ‘includes/content.crud’);
// Add a few content types to the field and use this loop:
foreach (array(‘TYPE1′, ‘TYPE2′, ‘TYPE3′, ‘TYPE4′) as $type) {
// … and change content type in the proper field.
$field[‘type_name’] = $type;
  content_field_instance_create($field);
}

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.