Browse Source

first commit of module developed by Rosie

main
Paul Pound 1 month ago
commit
2778b70a9d
  1. 3
      css/islandlives.css
  2. 9
      islandlives.info.yml
  3. 6
      islandlives.libraries.yml
  4. 41
      islandlives.module

3
css/islandlives.css

@ -0,0 +1,3 @@
tr.Unpublished {
background-color: #FFF4F4;
}

9
islandlives.info.yml

@ -0,0 +1,9 @@
name: IslandLives customization module
description: Hooks and custom elements for IslandLives.
package: Custom
type: module
core_version_requirement: ^9.4 || ^10
dependencies:
- pathauto:pathauto

6
islandlives.libraries.yml

@ -0,0 +1,6 @@
unpublished:
version: 1.x
css:
theme:
css/islandlives.css: {}

41
islandlives.module

@ -0,0 +1,41 @@
<?php
/**
* @file
* Custom hooks for Islandlives site.
*/
use Drupal\pathauto\PathautoPatternInterface;
use Drupal\views\ViewExecutable;
/**
* Implements hook_pathauto_pattern_alter().
*/
function islandlives_pathauto_pattern_alter(PathautoPatternInterface $pattern, array $context) {
// Only act on the repository_items pattern.
if ($pattern->id() == 'repository_items') {
// If node has no PID...
$node = $context['data']['node'];
$pid = $node->get('field_pid')->value;
if ($pid == NULL) {
// Replace the PID with the NID in the alias.
$new_pattern = preg_replace('/\[node:field_pid\]/', '[node:nid]', $pattern->getPattern());
$pattern->setPattern($new_pattern);
}
}
}
/**
* Implements hook_views_pre_render().
*/
function islandlives_views_pre_render(ViewExecutable $view) {
$applicable_views = [
'content',
'media',
'manage_members',
'media_of',
];
if (isset($view) && (in_array($view->storage->id(), $applicable_views))) {
$view->element['#attached']['library'][] = 'islandlives/unpublished';
}
}
Loading…
Cancel
Save