class views_plugin_row_node_view_split in Views nodes split 7
Same name and namespace in other branches
- 6 plugins/views_plugin_row_node_view_split.inc \views_plugin_row_node_view_split
Plugin which performs a node_view on the resulting object.
The difference between this plugin and the core node row plugin is that it can display the first nodes with a different view module.
Hierarchy
- class \views_object
- class \views_plugin
- class \views_plugin_row
- class \views_plugin
Expanded class hierarchy of views_plugin_row_node_view_split
1 string reference to 'views_plugin_row_node_view_split'
- views_nodes_split_views_plugins in ./
views_nodes_split.module - Implements hook_views_plugins().
File
- plugins/
views_plugin_row_node_view_split.inc, line 14 - Contains the node row plugin.
View source
class views_plugin_row_node_view_split extends views_plugin_row_node_view {
function option_definition() {
$options = parent::option_definition();
// Adds some new options.
$options['first_settings']['view_mode'] = array(
'default' => 'teaser',
);
$options['first_settings']['links'] = array(
'default' => TRUE,
);
$options['first_settings']['comments'] = array(
'default' => FALSE,
);
$options['first_settings']['first_x_value'] = array(
'default' => 0,
);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$options = $this
->options_form_summary_options();
$form['first_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Split settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['first_settings']['first_x_value'] = array(
'#type' => 'textfield',
'#title' => t('Split limit'),
'#description' => t('The results that are situated before or at this limit will have a different view mode.'),
'#default_value' => $this->options['first_settings']['first_x_value'],
);
$form['first_settings']['view_mode'] = array(
'#type' => 'select',
'#options' => $options,
'#title' => t('View mode'),
'#default_value' => $this->options['first_settings']['view_mode'],
);
$form['first_settings']['links'] = array(
'#type' => 'checkbox',
'#title' => t('Display links'),
'#default_value' => $this->options['first_settings']['links'],
);
$form['first_settings']['comments'] = array(
'#type' => 'checkbox',
'#title' => t('Display comments'),
'#default_value' => $this->options['first_settings']['comments'],
);
}
function summary_title() {
$options = $this
->options_form_summary_options();
return check_plain($options[$this->options['view_mode']] . ', ' . $options[$this->options['first_settings']['view_mode']]);
}
function render($row) {
// Some static variables that help us to identify at which result index
// are we in the current result set.
static $keys, $current_page, $items_per_page;
// If the static variables are not yet set, time to set them now.
if (!isset($keys)) {
$keys = array_keys($this->nodes);
}
if (!isset($current_page)) {
$current_page = $this->view
->get_current_page();
}
if (!isset($items_per_page)) {
$items_per_page = $this->view
->get_items_per_page();
}
$node = $this->nodes[$row->{$this->field_alias}];
$node->view = $this->view;
// The position of the node depends on the page we currently are and
// on the offset inside the current page.
$absolute_position = $current_page * $items_per_page + array_search($node->nid, $keys) + 1;
// Because we can have two view modes settings, we will store in the
// the $options array the correct set of options for this row (links and
// comments).
$options = $this->options;
// And now we check which view mode we should display.
if ($absolute_position <= $this->options['first_settings']['first_x_value']) {
// If we display the other view mode, also update the display settings.
$options = $this->options['first_settings'];
$build = node_view($node, $this->options['first_settings']['view_mode']);
}
else {
$build = node_view($node, $this->options['view_mode']);
}
// Check if we have to unset the links or set/unset the comments.
// Prevent the comment form from showing up if this is not a page display.
if ($options['view_mode'] == 'full' && !$this->view->display_handler
->has_path()) {
$node->comment = FALSE;
}
if (!$options['links']) {
unset($build['links']);
}
if (!empty($options['comments']) && user_access('access comments') && $node->comment) {
$build['comments'] = comment_node_page_additions($node);
}
return drupal_render($build);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
views_object:: |
public | property | Handler's definition. | |
views_object:: |
public | property | Except for displays, options for the object will be held here. | 1 |
views_object:: |
function | Collect this handler's option definition and alter them, ready for use. | ||
views_object:: |
public | function | Views handlers use a special construct function. | 4 |
views_object:: |
public | function | Destructor. | 2 |
views_object:: |
public | function | 1 | |
views_object:: |
public | function | ||
views_object:: |
public | function | Always exports the option, regardless of the default value. | |
views_object:: |
public | function | Set default options on this object. | 1 |
views_object:: |
public | function | Set default options. | |
views_object:: |
public | function | Let the handler know what its full definition is. | |
views_object:: |
public | function | Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. | |
views_object:: |
public | function | Unpack a single option definition. | |
views_object:: |
public | function | Unpacks each handler to store translatable texts. | |
views_object:: |
public | function | ||
views_plugin:: |
public | property | The current used views display. | |
views_plugin:: |
public | property | The plugin name of this plugin, for example table or full. | |
views_plugin:: |
public | property | The plugin type of this plugin, for example style or query. | |
views_plugin:: |
public | property |
The top object of a view. Overrides views_object:: |
1 |
views_plugin:: |
public | function | Provide a list of additional theme functions for the theme info page. | |
views_plugin:: |
public | function | Return the human readable name of the display. | |
views_plugin:: |
public | function | Provide a full list of possible theme templates used by this style. | |
views_plugin:: |
public | function | Validate that the plugin is correct and can be saved. | 3 |
views_plugin_row:: |
public | function |
Perform any necessary changes to the form values prior to storage.
There is no need for this function to actually store the data. Overrides views_plugin:: |
1 |
views_plugin_row:: |
public | function |
Validate the options form. Overrides views_plugin:: |
|
views_plugin_row:: |
public | function |
Add anything to the query that we might need to. Overrides views_plugin:: |
|
views_plugin_row:: |
public | function | ||
views_plugin_row_node_view:: |
public | property | ||
views_plugin_row_node_view:: |
public | property | Basic properties that let the row style follow relationships. | |
views_plugin_row_node_view:: |
public | property | Stores the nodes loaded with pre_render. | |
views_plugin_row_node_view:: |
public | function |
Overrides views_plugin_row:: |
|
views_plugin_row_node_view:: |
public | function | Return the main options, which are shown in the summary title. | |
views_plugin_row_node_view:: |
public | function |
Allow the style to do stuff before each row is rendered. Overrides views_plugin_row:: |
|
views_plugin_row_node_view_split:: |
function |
Provide a form for setting options. Overrides views_plugin_row_node_view:: |
||
views_plugin_row_node_view_split:: |
function |
Information about options for all kinds of purposes will be held here. Overrides views_plugin_row_node_view:: |
||
views_plugin_row_node_view_split:: |
function |
Render a row object. This usually passes through to a theme template
of some form, but not always. Overrides views_plugin_row_node_view:: |
||
views_plugin_row_node_view_split:: |
function |
Returns the summary of the settings in the display. Overrides views_plugin_row_node_view:: |