parallax_bg.module in Parallax Background 8
Same filename and directory in other branches
Contains parallax_bg.module.
File
parallax_bg.moduleView source
<?php
/**
* @file
* Contains parallax_bg.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function parallax_bg_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the parallax_bg module.
case 'help.page.parallax_bg':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Create a Parallax Background effect on any tagged element.') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_page_attachments().
*/
function parallax_bg_page_attachments(array &$attachments) {
$settings = [];
/** @var \Drupal\parallax_bg\Entity\ParallaxElementInterface[] $elements */
$elements = \Drupal::entityTypeManager()
->getStorage('parallax_element')
->loadMultiple();
foreach ($elements as $element) {
$settings[] = [
'selector' => $element
->getSelector(),
'position' => $element
->getPosition(),
'speed' => $element
->getSpeed(),
];
}
if (!empty($settings)) {
$attachments['#attached']['library'][] = 'parallax_bg/parallax_bg';
$attachments['#attached']['drupalSettings']['parallax_bg'] = $settings;
}
}
Functions
Name | Description |
---|---|
parallax_bg_help | Implements hook_help(). |
parallax_bg_page_attachments | Implements hook_page_attachments(). |