view_mode_page.module in View Mode Page 4.0.x
Same filename and directory in other branches
Contains view_mode_page module.
@TODO: Custom title (optionally) per pattern path @TODO: Set canonical (optionally) per pattern path
File
view_mode_page.moduleView source
<?php
/**
* @file
* Contains view_mode_page module.
*
* @TODO: Custom title (optionally) per pattern path
* @TODO: Set canonical (optionally) per pattern path
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Block\BlockPluginInterface;
/**
* Implements hook_help().
*/
function view_mode_page_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.view_mode_page':
$output = '';
$output .= '<p>' . t('Makes it possible to create (additional) paths where entities will be shown in a given view_mode') . '</p>';
return $output;
case 'entity.view_mode_page_pattern.collection':
$output = '<p>' . t('This page provides a list of all view_mode patterns on the site and allows you to edit and reorder them.') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_block_build_alter().
*
* Adds additional cache_contexts to the system_main_block, to prevent
* incorrect caching of a single view_mode (when using a path alias).
*/
function view_mode_page_block_build_alter(array &$build, BlockPluginInterface $block) {
if ($block
->getBaseId() == 'system_main_block') {
$build['#cache']['contexts'][] = 'url.path';
}
}
Functions
Name | Description |
---|---|
view_mode_page_block_build_alter | Implements hook_block_build_alter(). |
view_mode_page_help | Implements hook_help(). |