Hi

I'm toying with a little gallery module. I'd like to use the capabilities of CCK and imagefield. When installing the module it automatically adds a gallery content type. My problem is, that I can't seem to figure out how i tell CCK to automatically create an image field, and attach it to the content-type with a bunch of predefined settings (name of the field, multiple values etc.).

If anyone could guide me in the right direction it would be great.
Thanks

/ronnil

Comments

bwv’s picture

Which module are you using, the image module? I know that it will create a gallery for you.

If you want to use CCK and imagefield to create galleries, you can certainly do so, but those will have nothing to do with the image module per se.

You will need to create a custom content type, put an image field in it, allow multiple values (more than one image), then create a View that gives you the gallery you need.

Or are you talking about something completely different?
----------------------------------------------------------------------
http://classicvinyl.biz
http://music.bwv810.com
http://davidhertzberg.com
http://association.drupal.org/user/1207

I am a writer, researcher and solo drupal freelancer

Anonymous’s picture

I don't use a module, I'm creating one :)

I already made the content-type (done automatically). Right now i use the "file-attachments" to give me the image files. But I'd like for my module to automatically create the cck-field, so I don't have to do it via the administration each time I install the module.

bwv’s picture

Sorry, I don't think I can help with that. My (perhaps rudimentary) understanding is that a CCK field is assigned to a content type and that each time you create the content type, and CCK field is made available. In the absence of any other details, it sounds to me like you may be trying to reinvent the proverbial wheel. Good luck.
----------------------------------------------------------------------
http://classicvinyl.biz
http://music.bwv810.com
http://davidhertzberg.com
http://association.drupal.org/user/1207

I am a writer, researcher and solo drupal freelancer

sumitshekhawat7331’s picture

hello

I have seen your sites and it looks very attractive. and i also want to develop this type of site so could you tell me In your site "classicvinyl.biz" which modules are used and for which drupal version. and how create a combo box that will show all taxonomy terms.

Thanks in advance

2pha’s picture

I would also like to know how to add an imageField to the content type in my module

Sara Adams’s picture

I've been working on a module that (also) creates a content type, and adds a field to that content type. With some adjustments this should also work for your use case:


/**
* Implementation of hook_install().
*/
function dictionary_install() {
  // Create tables.
  drupal_install_schema('dictionary');
  // Add the node type.
  _dictionary_install_type_create();
  // Add iid field to node type.
  _dictionary_install_type_create_field();
}

function _dictionary_install_type_create() {
  // Create an additional node type.
  $dictionary_node_type = array(
    'type' => 'dictionary_term',
    'name' => t('Dictionary term'),
    'module' => 'node',
    'description' => t('A <em>dictionary term</em> is a page of content which gives describes or defines the terms listed in the dictionary. A dictionary term is references, and all translations of that term will be listed on the <em>dictionary term</em> page.'),
    'custom' => TRUE,
    'modified' => TRUE,
    'locked' => FALSE,
  );

  $dictionary_node_type = (object)_node_type_set_defaults($dictionary_node_type);
  node_type_save($dictionary_node_type);
  // Default to not promoted.
  variable_set('node_options_dictionary_term', array('status'));
}

function _dictionary_install_type_create_field() {
  // Create the iid reference field.
  $field = array(
    'type_name' => 'dictionary_term',
    'label' => 'Dictionary item reference',
    'field_name' => 'field_dictionary_term_iid',
    'type' => 'number_integer',
    'widget_type' => 'optionwidgets_select',
    'module' => 'number',
    'description' => 'The dictionary term that is being described in this node',
    'weight' => -4,
    'required' => TRUE,
    'multiple' => FALSE,
    'allowed_values_php' => "\$result = db_query('SELECT * FROM {dictionary_item} ORDER BY name');\r\n\$iids = array();\r\nwhile (\$item = db_fetch_object(\$result)) {\r\n  \$iids[\$item->iid] = \$item->name;\r\n}\r\nreturn \$iids;",
    'display_settings' => array('teaser' => array('exclude' => TRUE), 'full' => array('exclude' => TRUE)),
    'op' => 'Save field settings',
  );
  module_load_include('inc', 'content', 'includes/content.crud');
  $created_field = content_field_instance_create($field);
}

[Full source at http://users.conquer-space.net/~sara/dictionary-6.x.tgz]

Requirements: content (CCK), number, optionswidgets
The requirements will vary depending on the field you add.