You are here

public static function Bootstrap::isFront in Express 8

Determines if the current path is the "front" page.

*Note:* This method will not return `TRUE` if there is not a proper "cache_context.url.path.is_front" service defined.

*Note:* If using this method in preprocess/render array logic, the proper #cache context must also be defined:

```php $variables['#cache']['contexts'][] = 'url.path.is_front'; ```

Return value

bool TRUE or FALSE

See also

\Drupal\bootstrap\Bootstrap::hasIsFrontCacheContext

\Drupal\bootstrap\Bootstrap::preprocess

https://www.drupal.org/node/2829588

1 call to Bootstrap::isFront()
Bootstrap::preprocess in themes/contrib/bootstrap/src/Bootstrap.php
Preprocess theme hook variables.

File

themes/contrib/bootstrap/src/Bootstrap.php, line 1073
Contains \Drupal\bootstrap\Bootstrap.

Class

Bootstrap
The primary class for the Drupal Bootstrap base theme.

Namespace

Drupal\bootstrap

Code

public static function isFront() {
  static $is_front;
  if (!isset($is_front)) {
    try {
      $is_front = static::hasIsFrontCacheContext() ? \Drupal::service('path.matcher')
        ->isFrontPage() : FALSE;
    } catch (\Exception $e) {
      $is_front = FALSE;
    }
  }
  return $is_front;
}