You can create as many Feeds importer configurations as you would like to. Each can have a distinct purpose like letting your users aggregate RSS feeds or importing a CSV file for content migration. Here are a couple of things that are important to understand in order to get started with Feeds:
Define which elements of a single item of a feed (= Sources) map to which content pieces in Drupal (= Targets). Make sure that at least one definition has a Unique target. A unique target means that a value for a target can only occur once. E. g. only one item with the URL http://example.com/content/1 can exist.
'); } /** * Build overview of available configurations. */ function feeds_ui_overview_form($form, &$form_status) { $form = $form['enabled'] = $form['disabled'] = array(); $form['#header'] = array( t('Name'), t('Description'), t('Attached to'), t('Status'), t('Operations'), t('Enabled'), ); foreach (feeds_importer_load_all(TRUE) as $importer) { $importer_form = array(); $importer_form['name']['#markup'] = check_plain($importer->config['name']); $importer_form['description']['#markup'] = check_plain($importer->config['description']); if (empty($importer->config['content_type'])) { $importer_form['attached']['#markup'] = '[none]'; } else { if (!$importer->disabled) { $importer_form['attached']['#markup'] = l(node_type_get_name($importer->config['content_type']), 'node/add/'. str_replace('_', '-', $importer->config['content_type'])); } else { $importer_form['attached']['#markup'] = node_type_get_name($importer->config['content_type']); } } if ($importer->export_type == EXPORT_IN_CODE) { $status = t('Default'); $edit = t('Override'); $delete = ''; } else if ($importer->export_type == EXPORT_IN_DATABASE) { $status = t('Normal'); $edit = t('Edit'); $delete = t('Delete'); } else if ($importer->export_type == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) { $status = t('Overridden'); $edit = t('Edit'); $delete = t('Revert'); } $importer_form['status'] = array( '#markup' => $status, ); if (!$importer->disabled) { $importer_form['operations'] = array( '#markup' => l($edit, 'admin/structure/feeds/edit/'. $importer->id) .' | '. l(t('Export'), 'admin/structure/feeds/export/'. $importer->id) .' | '. l(t('Clone'), 'admin/structure/feeds/clone/'. $importer->id) . (empty($delete) ? '' : ' | '. l($delete, 'admin/structure/feeds/delete/'. $importer->id)), ); } else { $importer_form['operations']['#markup'] = ' '; } $importer_form[$importer->id] = array( '#type' => 'checkbox', '#default_value' => !$importer->disabled, '#attributes' => array('class' => array('feeds-ui-trigger-submit')), ); if ($importer->disabled) { $form['disabled'][$importer->id] = $importer_form; } else { $form['enabled'][$importer->id] = $importer_form; } } $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#attributes' => array('class' => array('feeds-ui-hidden-submit')), ); return $form; } /** * Submit handler for feeds_ui_overview_form(). */ function feeds_ui_overview_form_submit($form, &$form_state) { $disabled = array(); foreach (feeds_importer_load_all(TRUE) as $importer) { $disabled[$importer->id] = !$form_state['values'][$importer->id]; } variable_set('default_feeds_importer', $disabled); feeds_cache_clear(); } /** * Create a new configuration. * * @param $form_state * Form API form state array. * @param $from_importer * FeedsImporter object. If given, form will create a new importer as a copy * of $from_importer. */ function feeds_ui_create_form($form, &$form_state, $from_importer = NULL) { drupal_add_js(drupal_get_path('module', 'feeds_ui') .'/feeds_ui.js'); $form = array(); $form['#from_importer'] = $from_importer; $form['name'] = array( '#type' => 'textfield', '#title' => t('Name'), '#description' => t('A natural name for this configuration. Example: RSS Feed. You can always change this name later.'), '#required' => TRUE, '#maxlength' => 128, '#attributes' => array('class' => array('feed-name')), ); $form['id'] = array( '#type' => 'textfield', '#title' => t('Machine name'), '#description' => t('A unique identifier for this configuration. Example: rss_feed. Must only contain lower case characters, numbers and underscores.'), '#required' => TRUE, '#maxlength' => 128, '#attributes' => array('class' => array('feed-id')), ); $form['description'] = array( '#type' => 'textfield', '#title' => t('Description'), '#description' => t('A description of this configuration.'), ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Create'), ); return $form; } /** * Validation handler for feeds_build_create_form(). */ function feeds_ui_create_form_validate($form, &$form_state) { ctools_include('export'); $importer = feeds_importer($form_state['values']['id']); if (ctools_export_load_object('feeds_importer', 'conditions', array('id' => $form_state['values']['id']))) { form_set_error('id', t('Id is taken.')); } $importer->configFormValidate($form_state['values']); } /** * Submit handler for feeds_build_create_form(). */ function feeds_ui_create_form_submit($form, &$form_state) { // Create feed. $importer = feeds_importer($form_state['values']['id']); // If from_importer is given, copy its configuration. if (!empty($form['#from_importer'])) { $importer->copy($form['#from_importer']); } // In any case, we want to set this configuration's title and description. $importer->addConfig($form_state['values']); $importer->save(); // Set a message and redirect to settings form. if (empty($form['#from_importer'])) { drupal_set_message(t('Your configuration has been created with default settings. If they do not fit your use case you can adjust them here.')); } else { drupal_set_message(t('A clone of the !name configuration has been created.', array('!name' => $form['#from_importer']->config['name']))); } $form_state['redirect'] = 'admin/structure/feeds/edit/'. $importer->id; feeds_cache_clear(); } /** * Delete configuration form. */ function feeds_ui_delete_form($form, &$form_state, $importer) { $form['#importer'] = $importer; if ($importer->export_type & EXPORT_IN_CODE) { $title = t('Would you really like to revert the importer @importer?', array('@importer' => $importer->config['name'])); $button_label = t('Revert'); } else { $title = t('Would you really like to delete the importer @importer?', array('@importer' => $importer->config['name'])); $button_label = t('Delete'); } return confirm_form($form, $title, 'admin/structure/feeds', t('This action cannot be undone.'), $button_label); } /** * Submit handler for feeds_ui_delete_form(). */ function feeds_ui_delete_form_submit($form, &$form_state) { $form_state['redirect'] = 'admin/structure/feeds'; // Remove importer. $form['#importer']->delete(); // Clear cache, deleting a configuration may have an affect on menu tree. feeds_cache_clear(); } /** * Export a feed configuration. */ function feeds_ui_export_form($form, &$form_state, $importer) { $code = feeds_export($importer->id); $form['export'] = array( '#title' => t('Export feed configuration'), '#type' => 'textarea', '#value' => $code, '#rows' => substr_count($code, "\n"), ); return $form; } /** * Edit feed configuration. */ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') { // Get plugins and configuration. $plugins = FeedsPlugin::all(); $config = $importer->config; // Base path for changing the active container. $path = 'admin/structure/feeds/edit/'. $importer->id; $active_container = array( 'class' => array('active-container'), 'actions' => array(l(t('Help'), $path)), ); switch ($active) { case 'help': $active_container['title'] = t('Getting started'); $active_container['body'] = '