Guest User

Untitled

a guest
May 28th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. /**
  2. * Implements template_preprocess_node.
  3. */
  4. function MYTHEME/MYMODULE_preprocess_node(&$variables) {
  5.  
  6. // Check for node type.
  7. if ($variables['node']->getType() == 'artist') {
  8.  
  9. $current_path = Drupal::service('path.current')->getPath();
  10. $current_alias = Drupal::service('path.alias_manager')->getAliasByPath($current_path);
  11. $alias_args = explode('/', $current_alias);
  12.  
  13. // 1. Unset content per path alias.
  14. if ((isset($alias_args[0]) && $alias_args[0] == 'details')
  15. && (isset($alias_args[1]) && $alias_args[1] == 'michael-jackson')) {
  16. unset($variables['content']);
  17. }
  18.  
  19. // 2. Or unset content by node ID.
  20. if ($variables['node']->id() == '123') {
  21. unset($variables['content']);
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment