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'; } }