views_slideshow_xtra_example.module in Views Slideshow Xtra 7
Same filename and directory in other branches
This module creates a Views Slideshow Xtra content type and example slide nodes.
File
views_slideshow_xtra_example/views_slideshow_xtra_example.moduleView source
<?php
/**
* @file
* This module creates a Views Slideshow Xtra content type and
* example slide nodes.
*/
/**
* Implements hook_menu().
*/
function views_slideshow_xtra_example_menu() {
// Create example vsx nodes.
$items['views-slideshow-xtra-example-nodes'] = array(
'page callback' => 'views_slideshow_xtra_example_nodes',
'access arguments' => array(
'access content',
),
'title' => 'Create Views Slideshow Xtra Example Nodes',
);
return $items;
}
/**
* Implements hook_help().
*/
function views_slideshow_xtra_example_help($path, $arg) {
switch ($path) {
case 'views_slideshow_xtra_example':
return "<p>" . t("This module provides an example node type and nodes for Views Slideshow Xtra slides.") . "</p>";
}
}
/**
* Create three example slide nodes with image and overlay elements.
*/
function views_slideshow_xtra_example_nodes() {
// Slide 1
$node1 = new stdClass();
$node1->type = 'views_slideshow_xtra';
node_object_prepare($node1);
$node1->title = 'Views Slideshow Xtra Example Slide 1 ' . date('c');
$node1->language = LANGUAGE_NONE;
// Slide 1 Overlay Elements
$node1->views_slideshow_xtra[$node1->language][0]['value'] = '{"type":"text", "top": 50, "left": 150, "text":"Slide 1 Text Element 1", "example":"true"}';
$node1->views_slideshow_xtra[$node1->language][1]['value'] = '{"type":"text", "top": 100, "left": 150, "text":"Slide 1 Text Element 2", "example":"true"}';
$node1->views_slideshow_xtra[$node1->language][2]['value'] = '{"type":"link", "top": 150, "left": 150, "text":"Link to Drupal.org", "url": "http://drupal.org", "example":"true"}';
// Slide 1 Image
$image_directory = drupal_get_path('module', 'views_slideshow_xtra_example') . '/example_images/';
$filepath = drupal_realpath($image_directory . 'vsx-slide-four-mile.jpg');
// Create a File object
$file = (object) array(
'uid' => 1,
'uri' => $filepath,
'filemime' => file_get_mimetype($filepath),
'status' => 1,
);
$file = file_copy($file, 'public://');
// Save the file to the root of the files directory. You can specify a subdirectory, for example, 'public://images'
$node1->views_slideshow_image[LANGUAGE_NONE][0] = (array) $file;
//associate the file object with the image field:
node_save($node1);
// Slide 2
$node2 = new stdClass();
$node2->type = 'views_slideshow_xtra';
node_object_prepare($node2);
$node2->title = 'Views Slideshow Xtra Example Slide 2 ' . date('c');
$node2->language = LANGUAGE_NONE;
// Slide 2 Overlay Elements
$node2->views_slideshow_xtra[$node2->language][0]['value'] = '{"type":"text", "top": 50, "left": 50, "text":"Slide 2 Text Element 1", "example":"true"}';
$node2->views_slideshow_xtra[$node2->language][1]['value'] = '{"type":"text", "top": 100, "left": 50, "text":"Slide 2 Text Element 2", "example":"true"}';
$node2->views_slideshow_xtra[$node2->language][2]['value'] = '{"type":"link", "top": 50, "left": 200, "text":"Link to Google.com", "url": "http://google.com", "example":"true"}';
$node2->views_slideshow_xtra[$node2->language][3]['value'] = '{"type":"link", "top": 100, "left": 200, "text":"Link to Yahoo.com", "url": "http://yahoo.com", "example":"true"}';
// Slide 2 Image
$image_directory = drupal_get_path('module', 'views_slideshow_xtra_example') . '/example_images/';
$filepath = drupal_realpath($image_directory . 'vsx-slide-mount-princeton.jpg');
// Create a File object
$file = (object) array(
'uid' => 1,
'uri' => $filepath,
'filemime' => file_get_mimetype($filepath),
'status' => 1,
);
$file = file_copy($file, 'public://');
// Save the file to the root of the files directory. You can specify a subdirectory, for example, 'public://images'
$node2->views_slideshow_image[LANGUAGE_NONE][0] = (array) $file;
//associate the file object with the image field:
node_save($node2);
// Slide 3
$node3 = new stdClass();
$node3->type = 'views_slideshow_xtra';
node_object_prepare($node3);
$node3->title = 'Views Slideshow Xtra Example Slide 3 ' . date('c');
$node3->language = LANGUAGE_NONE;
// Slide 3 Overlay Elements
$node3->views_slideshow_xtra[$node3->language][0]['value'] = '{"type":"text", "top": 50, "left": 100, "text":"Slide 3 Text Element 1", "example":"true"}';
$node3->views_slideshow_xtra[$node3->language][1]['value'] = '{"type":"text", "top": 80, "left": 140, "text":"Slide 3 Text Element 2", "example":"true"}';
// Slide 3 Image
$image_directory = drupal_get_path('module', 'views_slideshow_xtra_example') . '/example_images/';
$filepath = drupal_realpath($image_directory . 'vsx-slide-mount-yale-treeline.jpg');
// Create a File object
$file = (object) array(
'uid' => 1,
'uri' => $filepath,
'filemime' => file_get_mimetype($filepath),
'status' => 1,
);
$file = file_copy($file, 'public://');
// Save the file to the root of the files directory. You can specify a subdirectory, for example, 'public://images'
$node3->views_slideshow_image[LANGUAGE_NONE][0] = (array) $file;
//associate the file object with the image field:
node_save($node3);
}
Functions
Name![]() |
Description |
---|---|
views_slideshow_xtra_example_help | Implements hook_help(). |
views_slideshow_xtra_example_menu | Implements hook_menu(). |
views_slideshow_xtra_example_nodes | Create three example slide nodes with image and overlay elements. |