It is passible to enable or disable the „Display author and date information“ for each node depending on the content of a field?
The base:
Drupal 8.3.0 (rc2)
field „Where to publish“
- Case 1: field „Where to publish“ = „public“
- Case 2: field „Where to publish“ = „internally“
-> in Case 1: disable „Display author and date information“
-> in Case 2: enable „Display author and date information“
How can this be realized? Is that possible? Or should I use two different content types?
First part runs:
function kanu_preprocess_node(&$variables) {
if ($variables['node']->getType() != 'test') {
return;
}
$field = $variables['node']->field_where_to_publish;
}
Completed it returns an unexpected error:
function kanu_preprocess_node(&$variables) {
if ($variables['node']->getType() != 'test') {
return;
}
$field = $variables['node']->field_where_to_publish;
if (!field->isEmpty() && $field->entity->label() == 'public') {
$variables['display_submitted'] = FALSE;
}
}