Skip to main content
Joachim's blog

Main navigation

  • Home
  • About
  • Hire me

Breadcrumb

  1. Home

cck

By joachim, Wed, 04/11/2009 - 15:19

Creating A Set Of Fields In One Swell Foop

Situation: you need a heap of imagefields that more or less have the same setup. Let's not go into why.

You could spend half an hour bored witless clicking through the interface.

Or you could create just the one field, export the content type with content copy, and then doctor the code a little before importing it back in. Like this....

<?php
// The usual content type stuff here.
// Set of image fields
$image_fields = array(
'field_image_1' => 'Image 1',
'field_image_2' => 'Image 2',
// etc
);

foreach ($image_fields as $name => $label) {

Tags

  • drupal
  • 6.x
  • cck
  • drupal planet
cck

Frequent tags

  • Drupal Code Builder (9)
  • git (7)
  • module builder (7)
  • 6.x (5)
  • drupal commerce (4)
  • development (3)
  • Entity API (3)
  • tests (3)
  • Field API (3)
  • patching (3)
  • Rector (3)
  • Composer (3)
  • Drush (3)
  • contributing code (3)
  • drupal.org (2)
  • debugging (2)
  • deprecation (2)
  • multisite (2)
  • core (2)
  • issue queue (2)
  • Drupal core (2)
  • roadmap (2)
  • 7.x (2)
  • modules (2)
  • developer tools (2)
  • wtf (2)
  • code style (2)
  • contrib module (2)
  • maintaining projects (2)
Powered by Drupal