You are here

social_page.module in Open Social 8.4

Contains social_page.module..

File

modules/social_features/social_page/social_page.module
View source
<?php

/**
 * @file
 * Contains social_page.module..
 */
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use Drupal\node\NodeInterface;

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

    // Main module help for the social_page module.
    case 'help.page.social_page':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Use basic pages for your static content, such as an about page.') . '</p>';
      return $output;
    default:
  }
}

/**
 * Implements hook_node_links_alter().
 */
function social_page_node_links_alter(array &$links, NodeInterface $entity, array &$context) {

  // Remove the add new comment link.
  unset($links['comment__field_page_comments']['#links']['comment-add']);
}

/**
 * Implements hook_social_user_account_header_create_links().
 *
 * Adds the "Create Page" link to the content creation menu.
 */
function social_page_social_user_account_header_create_links($context) {
  return [
    'add_page' => [
      '#type' => 'link',
      '#attributes' => [
        'title' => new TranslatableMarkup('Create New Page'),
      ],
      '#title' => new TranslatableMarkup('New Page'),
      '#weight' => 300,
    ] + Url::fromRoute('node.add', [
      'node_type' => 'page',
    ])
      ->toRenderArray(),
  ];
}