commit 2778b70a9d708048783f99e66a9c7ca1502f4534 Author: Paul Pound Date: Tue Nov 12 13:41:15 2024 -0400 first commit of module developed by Rosie diff --git a/css/islandlives.css b/css/islandlives.css new file mode 100644 index 0000000..43a3109 --- /dev/null +++ b/css/islandlives.css @@ -0,0 +1,3 @@ +tr.Unpublished { + background-color: #FFF4F4; +} \ No newline at end of file diff --git a/islandlives.info.yml b/islandlives.info.yml new file mode 100644 index 0000000..3487cd2 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/islandlives.libraries.yml b/islandlives.libraries.yml new file mode 100644 index 0000000..e3c92ee --- /dev/null +++ b/islandlives.libraries.yml @@ -0,0 +1,6 @@ +unpublished: + version: 1.x + css: + theme: + css/islandlives.css: {} + \ No newline at end of file diff --git a/islandlives.module b/islandlives.module new file mode 100644 index 0000000..e6071ee --- /dev/null +++ b/islandlives.module @@ -0,0 +1,41 @@ +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'; + } +}