function views_slideshow_xtra_example_nodes in Views Slideshow Xtra 7
Same name and namespace in other branches
- 7.3 views_slideshow_xtra_example/views_slideshow_xtra_example.module \views_slideshow_xtra_example_nodes()
- 7.2 views_slideshow_xtra_example/views_slideshow_xtra_example.module \views_slideshow_xtra_example_nodes()
Create three example slide nodes with image and overlay elements.
1 string reference to 'views_slideshow_xtra_example_nodes'
- views_slideshow_xtra_example_menu in views_slideshow_xtra_example/
views_slideshow_xtra_example.module - Implements hook_menu().
File
- views_slideshow_xtra_example/
views_slideshow_xtra_example.module, line 34 - This module creates a Views Slideshow Xtra content type and example slide nodes.
Code
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);
}