You are here

sticky.module in Sticky 8

Same filename and directory in other branches
  1. 2.0.x sticky.module

Contains sticky.module..

File

sticky.module
View source
<?php

/**
 * @file
 * Contains sticky.module..
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function sticky_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the sticky module.
    case 'help.page.sticky':
      $output = file_get_contents(drupal_get_path('module', 'sticky') . '/README.txt');
      return '<pre>' . $output . '</pre>';
    default:
  }
}

/**
 * Implements hook_page_attachments().
 */
function sticky_page_attachments(array &$attachments) {

  /** @var \Drupal\sticky\Manager\StickyManager $manager */
  $manager = Drupal::service('sticky.manager');

  // Pass the sticky settings.
  $attachments['#attached']['drupalSettings']['sticky'] = $manager
    ->getJsSettings();

  // Load the sticky js library.
  $attachments['#attached']['library'][] = 'sticky/sticky';
}

Functions

Namesort descending Description
sticky_help Implements hook_help().
sticky_page_attachments Implements hook_page_attachments().