You are here

views_slideshow_xtra_example.install in Views Slideshow Xtra 7.2

Install file for Views Slideshow Xtra Example module.

File

views_slideshow_xtra_example/views_slideshow_xtra_example.install
View source
<?php

/**
 * @file
 * Install file for Views Slideshow Xtra Example module.
 */

/**
 * Implements hook_install().
 */
function views_slideshow_xtra_example_install() {
  $t = get_t();

  // Define the node type.
  $node_vsx = array(
    'type' => 'views_slideshow_xtra',
    'custom' => 1,
    'name' => $t('Views Slideshow Xtra'),
    'base' => 'node_content',
    'description' => $t('Node type used for making Views Slideshows Xtra Slides.'),
  );
  $content_type = node_type_set_defaults($node_vsx);
  node_type_save($content_type);

  // Create all the fields we are adding to our content type.
  // http://api.drupal.org/api/function/field_create_field/7
  foreach (_views_slideshow_xtra_example_installed_fields() as $field) {
    field_create_field($field);
  }

  // Create all the instances for our fields.
  // http://api.drupal.org/api/function/field_create_instance/7
  foreach (_views_slideshow_xtra_example_installed_instances() as $instance) {
    $instance['entity_type'] = 'node';
    $instance['bundle'] = $node_vsx['type'];
    field_create_instance($instance);
  }
}

/**
 * Return a structured array defining the fields created by this content type.
 */
function _views_slideshow_xtra_example_installed_fields() {
  $t = get_t();
  return array(
    'views_slideshow_xtra' => array(
      'field_name' => 'views_slideshow_xtra',
      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
      'type' => 'text',
      'settings' => array(
        'max_length' => 512,
      ),
    ),
    'views_slideshow_image' => array(
      'field_name' => 'views_slideshow_image',
      'type' => 'image',
      'cardinality' => 1,
    ),
  );
}

/**
 * Return a structured array defining the instances for this content type.
 */
function _views_slideshow_xtra_example_installed_instances() {
  $t = get_t();
  return array(
    'views_slideshow_xtra' => array(
      'field_name' => 'views_slideshow_xtra',
      'label' => $t('Views Slideshow Xtra Overlay Elements'),
      'required' => FALSE,
      'widget' => array(
        'type' => 'text_textfield',
      ),
    ),
    'views_slideshow_image' => array(
      'field_name' => 'views_slideshow_image',
      'label' => $t('Views Slideshow Slide Image'),
      'required' => FALSE,
      'widget' => array(
        'type' => 'image_image',
      ),
    ),
  );
}

Functions

Namesort descending Description
views_slideshow_xtra_example_install Implements hook_install().
_views_slideshow_xtra_example_installed_fields Return a structured array defining the fields created by this content type.
_views_slideshow_xtra_example_installed_instances Return a structured array defining the instances for this content type.