Enable/ disable „Display author and date information“ per node? 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(&amp;$variables) {
if ($variables['node']-&gt;getType() != 'test') {
    return;
  }
$field = $variables['node']-&gt;field_where_to_publish;
}


Completed it returns an unexpected error:

function kanu_preprocess_node(&amp;$variables) {
  if ($variables['node']-&gt;getType() != 'test') {
      return;
  }
  $field = $variables['node']-&gt;field_where_to_publish;

  if (!field-&gt;isEmpty() &amp;&amp; $field-&gt;entity-&gt;label() == 'public') {
     $variables['display_submitted'] = FALSE;
  }
}
You can override the variable display_submitted in a preprocess hook:

mytheme.theme:

function mytheme_preprocess_node(&amp;$variables) {

  // check if this is the right content type where the field exists
  if ($variables['node']-&gt;getType() != 'article') {
    return;
  }

  // plain field
  if ($variables['node']-&gt;field_where_to_publish-&gt;value == 'public') {
    $variables['display_submitted'] = FALSE;
  }

  // taxonomy field
  $field = $variables['node']-&gt;field_where_to_publish;
  if (!$field-&gt;isEmpty() &amp;&amp; $field-&gt;entity-&gt;label() == 'public') {
    $variables['display_submitted'] = FALSE;
  }

}