embed_views.module in Embed Views Display 7.2
Same filename and directory in other branches
Integration with the views module to create the new embed views display.
File
embed_views.moduleView source
<?php
/**
* @file
* Integration with the views module to create the new embed views display.
*/
/**
* Implements hook_views_api().
*/
function embed_views_views_api() {
return array(
"version" => "3.0",
);
}
/**
* Implementation of hook_views_plugins().
*/
function embed_views_views_plugins() {
return array(
'display' => array(
'embed' => array(
'title' => t('Embed'),
'help' => t('Creates a display for embed use.'),
'path' => drupal_get_path('module', 'embed_views'),
'file' => 'embed_views_plugin_display_embed.inc',
'handler' => 'embed_views_plugin_display_embed',
'theme' => 'views_view',
'theme path' => drupal_get_path('module', 'views') . '/theme',
'use ajax' => TRUE,
'use pager' => TRUE,
'use more' => TRUE,
'accept attachments' => TRUE,
'help topic' => 'embed',
),
),
);
}
/**
* Implementation of hook_form_FORM_ID_alter().
*/
function embed_views_form_views_exposed_form_alter(&$form, &$form_state) {
// Change the action of the form for all embed views.
if ($form_state['display']->display_plugin == 'embed') {
$form['#action'] = url(drupal_get_path_alias($_GET['q']));
}
}
/**
* Implements hook_views_plugins_alter().
*
* - Override views' built-in embed display.
*/
function embed_views_views_plugins_alter(&$plugins) {
$embed_views_display = embed_views_views_plugins();
$plugins['display']['embed'] = array_merge($plugins['display']['embed'], $embed_views_display['display']['embed']);
}
/**
* Returns the exposed filter widgets for a view.
*
* @param mixed $view
* Either a string with the name of the view or an object of the view
* @param string $display_id
* An optional string with the name of the display for the view.
*
* @return string
* The themed exposed filter form.
*/
function embed_views_exposed_form($view, $display_id = '') {
$destroy = FALSE;
if (is_string($view) && $display_id != '') {
$destroy = TRUE;
$view = views_get_view($view);
$view
->set_display((string) $display_id);
}
elseif ($display_id != '') {
$view
->set_display((string) $display_id);
}
if (isset($view->display_handler)) {
$exposed_filter = $view->display_handler
->embed_views_exposed_form();
// Cleanup if we created.
if ($destroy == '') {
$view
->destroy();
}
return $exposed_filter;
}
else {
watchdog('embed_views', t('You must set the display BEFORE you call embed_views_exposed_form().'), array(), WATCHDOG_ERROR);
}
}
Functions
Name![]() |
Description |
---|---|
embed_views_exposed_form | Returns the exposed filter widgets for a view. |
embed_views_form_views_exposed_form_alter | Implementation of hook_form_FORM_ID_alter(). |
embed_views_views_api | Implements hook_views_api(). |
embed_views_views_plugins | Implementation of hook_views_plugins(). |
embed_views_views_plugins_alter | Implements hook_views_plugins_alter(). |