views_entity_embed.module in Views entity embed 8
Same filename and directory in other branches
Contains main hooks of Views Entity Embed.
File
views_entity_embed.moduleView source
<?php
/**
* @file
* Contains main hooks of Views Entity Embed.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function views_entity_embed_help($route_name, RouteMatchInterface $route_match) {
if ($route_name == 'help.page.views_entity_embed') {
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Views entity embed module provides Views to be embed with CKE Editor.') . '</p>';
return $output;
}
}
/**
* Implements hook_theme().
*/
function views_entity_embed_theme() {
return [
'views_entity_embed_container' => [
'render element' => 'element',
'path' => drupal_get_path('module', 'views_entity_embed') . '/templates',
],
];
}
/**
* Prepares variables for views entity embed container templates.
*
* Default template: views-entity-embed-container.html.twig.
*
* @param array $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #attributes, #view.
*/
function template_preprocess_views_entity_embed_container(array &$variables) {
$variables['element'] += [
'#attributes' => [],
];
$variables['attributes'] = $variables['element']['#attributes'];
$variables['element']['#view']->element['#embed_context'] = $variables['element']['#context'];
$variables['view'] = $variables['element']['#view']
->render();
}
/**
* Implements hook_preprocess_views_view().
*/
function views_entity_embed_preprocess_views_view(array &$variables) {
$view = $variables['view'];
// Override title of embed settings.
if (isset($view->element['#embed_context']) && $view->element['#embed_context']['data-override-title']) {
$variables['title'] = $view->element['#embed_context']['data-title'];
}
}
Functions
Name | Description |
---|---|
template_preprocess_views_entity_embed_container | Prepares variables for views entity embed container templates. |
views_entity_embed_help | Implements hook_help(). |
views_entity_embed_preprocess_views_view | Implements hook_preprocess_views_view(). |
views_entity_embed_theme | Implements hook_theme(). |