Commit 85c8d12e authored by catch's avatar catch

Issue #1852966 by yched, amateescu: (Doc fixes followup) Rework entity display...

Issue #1852966 by yched, amateescu: (Doc fixes followup) Rework entity display settings around EntityDisplay config entity.
parent 8f03af99
...@@ -290,12 +290,13 @@ function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInter ...@@ -290,12 +290,13 @@ function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInter
* - bundle: The bundle, e.g., 'page' or 'article'. * - bundle: The bundle, e.g., 'page' or 'article'.
* - view_mode: The view mode, e.g. 'full', 'teaser'... * - view_mode: The view mode, e.g. 'full', 'teaser'...
*/ */
function hook_entity_display_alter(Drupal\field\Plugin\Core\Entity\EntityDisplay $display, array $context) { function hook_entity_display_alter(\Drupal\entity\Plugin\Core\Entity\EntityDisplay $display, array $context) {
// Leave field labels out of the search index. // Leave field labels out of the search index.
if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') { if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') {
foreach ($display->content as $name => &$properties) { foreach ($display->getComponents() as $name => $options) {
if (isset($properties['label'])) { if (isset($options['label'])) {
$properties['label'] = 'hidden'; $options['label'] = 'hidden';
$display->setComponent($name, $options);
} }
} }
} }
......
...@@ -581,7 +581,7 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL) { ...@@ -581,7 +581,7 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL) {
* - Set the 'body' field to be displayed and the 'field_image' field to be * - Set the 'body' field to be displayed and the 'field_image' field to be
* hidden on article nodes in the 'default' display. * hidden on article nodes in the 'default' display.
* @code * @code
* entity_get_display('article', 'node', 'default') * entity_get_display('node', 'article', 'default')
* ->setComponent('body', array( * ->setComponent('body', array(
* 'type' => 'text_summary_or_trimmed', * 'type' => 'text_summary_or_trimmed',
* 'settings' => array('trim_length' => '200') * 'settings' => array('trim_length' => '200')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment