Drupal 8 notes

Сообщение об ошибке

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls в функции menu_set_active_trail() (строка 2405 в файле /var/www/notes7/includes/menu.inc).
  1. urls
    $current_url = \Drupal\Core\Url::fromRoute('<current>', array(), array("absolute" => TRUE))->toString();  // get full url

     

  2. Variables
    Drupal\Core\Site\Settings::get('some_setting_here'); // Get a setting from settings.php

     

  3. Nodes
    $id = $node->id(); // get node id
    $node_type = $node->getType(); // get node type
    // get terms ids related to node
    $terms = $node->get('field_sometaxonomyfield')->getValue();
    $terms = array_column($terms, 'target_id');

     

  4. Twig
    Print full url
    {{ url('<current>') }}

    Raw value of a field

    {{ node.field_somefield.value }}

    print image from image_field

    {{ content.field_imagefield.0 }}

     

Добавить комментарий

CAPTCHA