Attached patch includes a snippet of code to facilitate importing in content_copy. This can save the need for site admins to copy and paste text from a file. Instead, we feed in a file path and it's pre-loaded in the macro field.

And a sample usage:


  // If Content Copy is enabled, offer an import link.
  if (module_exists('content_copy')) {
    $form['macro'] = array(
      '#type' => 'fieldset',
      '#title' => t('Create a content type'),
      '#description' => t('Follow this link to create automatically a content type and import preconfigured fields.'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['macro']['link'] = array(
      '#type' => 'markup',
      '#value' => l(t('import'), 'admin/content/types/import', array(), 'macro_file='. drupal_get_path('module', 'my_module') .'/my_content_type.txt'),
    );
  }

CommentFileSizeAuthor
content_copy-preload.patch805 bytesnedjo

Comments

moshe weitzman’s picture

nifty ... eaton is working on code defined fields and so on ... not sure what committers could so with this snippit.

drewish’s picture

Did this feature make it anywhere? I'm really keen on the idea of being able to define fields as part of a hook_install() or hook_update_N().

karens’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev

Bumping this forward. It seems like a simple thing to add and it should still apply, I just don't have time to test it.

I think we need to move the snippet into some documentation as an example of how to implement it. It could go in the PHP docs, or in a README.txt.

karens’s picture

Status: Needs review » Fixed

Since this is such a simple thing, I committed this to both D5 and D6. I altered it a bit so you can provide either just a macro to create a new content type or specify a specific content type to add the fields to, and I put the example into the PHP docs for Content Copy's import form.

I'm implementing this in the Date Copy module to add a link to easily add a Date field to an Event content type.

The really nice thing about this is that you don't have to do any fancy formatting of the import file, just paste your export text into a text file and link to it and it works fine.

Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.