This accepts views arguments as well:
{{ drupal_view('who_s_new', 'block_1') }}
{{ drupal_view('who_s_new', 'block_1' 'contextarg1', 'contextarg2', '...') }}
<?php | |
function lib_layouts_entity_view_mode_alter(&$view_mode, EntityInterface $entity, $context) { | |
if ($entity->getEntityTypeId() == 'node' && $entity->bundle() == 'landing_page' && $view_mode == 'full') { | |
if ($entity->hasField('field_layout')) { | |
$field = $entity->get('field_layout'); | |
if (!$field->isEmpty()) { | |
$layout = $entity->get('field_layout')->getString(); | |
$available_modes = \Drupal::service('entity_display.repository')->getViewModes('node'); | |
if (array_key_exists($layout, $available_modes)) { |
<?php | |
// Basics | |
// Get a value. | |
$value = $wrapper->field_x->value(); | |
// If the field is a reference field you will get the field object | |
// To get the wrapper back use: | |
$wrapper_b = $wrapper->field_ref; | |
// To set a value. |