Active
Project:
Views Custom Field
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 Apr 2011 at 17:07 UTC
Updated:
2 Apr 2011 at 17:07 UTC
Hi,
I'm trying to create a slideshow using Views_Slideshow of multiple videos and images per node.
This is the view I have:
$view = new view;
$view->name = 'portfoliocarousel';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'field_portfolio_video_embed' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => 0,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 1,
'id' => 'field_portfolio_video_embed',
'table' => 'node_data_field_portfolio_video',
'field' => 'field_portfolio_video_embed',
'relationship' => 'none',
),
'field_portfolio_images_fid' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'homecarousel_default',
'multiple' => array(
'group' => 0,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 1,
'id' => 'field_portfolio_images_fid',
'table' => 'node_data_field_portfolio_images',
'field' => 'field_portfolio_images_fid',
'relationship' => 'none',
),
'phpcode' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'value' => '<?php if ($data->field_portfolio_video) {
echo $data->field_portfolio_video;
}
else {
echo $data->field_portfolio_portfolios;
} ?>',
'exclude' => 0,
'id' => 'phpcode',
'table' => 'customfield',
'field' => 'phpcode',
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'nid' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'node',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'nid',
'table' => 'node',
'field' => 'nid',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_fixed' => '',
'default_argument_user' => 0,
'default_argument_php' => '',
'validate_argument_node_type' => array(
'carousel' => 0,
'clients' => 0,
'clients_testimonials' => 0,
'news' => 0,
'page' => 0,
'portfolio_piece' => 0,
'team_member' => 0,
'webform' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'2' => 0,
'1' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'portfolio_piece' => 'portfolio_piece',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('items_per_page', 0);
$handler->override_option('style_plugin', 'slideshow');
$handler->override_option('style_options', array(
'type' => 'ul',
'mode' => 'views_slideshow_singleframe',
'views_slideshow_singleframe-prefix' => '',
'views_slideshow_singleframe' => array(
'timeout' => '5000',
'delay' => '0',
'speed' => '700',
'start_paused' => 1,
'fixed_height' => '1',
'random' => '0',
'pause' => '1',
'pause_on_click' => '0',
'pause_when_hidden' => 0,
'pause_when_hidden_type' => 'full',
'amount_allowed_visible' => '',
'remember_slide' => 0,
'remember_slide_days' => '1',
'controls' => '1',
'pager' => '0',
'pager_type' => 'Numbered',
'pager_hover' => '2',
'pager_click_to_page' => 0,
'image_count' => '0',
'items_per_slide' => '1',
'effect' => 'scrollHorz',
'sync' => '1',
'nowrap' => '0',
'advanced' => '',
'ie' => array(
'cleartype' => 'false',
'cleartypenobg' => 'false',
),
),
));
$handler->override_option('row_plugin', 'semanticviews_fields');
$handler->override_option('row_options', array(
'semantic_html' => array(
'field_portfolio_video_embed' => array(
'element_type' => 'div',
'class' => '',
),
'field_video_desc_value' => array(
'element_type' => 'div',
'class' => '',
),
'field_portfolio_images_fid' => array(
'element_type' => 'div',
'class' => '',
),
'field_portfolio_images_data' => array(
'element_type' => 'div',
'class' => '',
),
),
'skip_blank' => 1,
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
This is the customfield code I'm playing around with but I'm not sure how to say if there are videos show the videos (one per slide) and if not show the images (again one per slide.)
<?php if ($data->field_portfolio_video) {
echo $data->field_portfolio_video;
}
else {
echo $data->field_portfolio_portfolios;
} ?>Any help would be gratefuly received, thanks!