Drupal 8 $GLOBALS

In Drupal 8, global $user has been deprecated in favor of a current_user service.

Drupal 7:

public function behave() {
  global $user;
  if ($user->uid == 1) {
    return "Hiya, boss!";
  }
  else {
    return "You are not the site administrator.";
  }
}

Drupal 8:

public function behave() {
  $account = \Drupal::currentUser();
  if ($account->id() == 1) {
    return "Hiya, boss!";
  }
  else {
    return "You are not the site administrator.";
  }
}

 

global $base_url and $base_path

<?php
global $base_url;   // Will point to http://www.example.com
global $base_path;  // Will point to at least "/" or the subdirectory where the drupal in installed.
$link = $base_url . $base_path . 'node/add';

?>

 

Read more...

Sample blackbox block

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas non porta odio, id mattis erat.

Nam sed tincidunt eros. Donec a venenatis odio, vitae commodo sem. Vivamus ullamcorper pellentesque erat, in adipiscing tortor scelerisque sit amet. Nulla pulvinar urna magna. Vivamus a ipsum lorem. Etiam adipiscing pulvinar lorem.