template_preprocess_node_add_list

template_preprocess_node_add_list(&$variables)

Prepares variables for list of available node type templates.

Default template: node-add-list.html.twig.

Parameters

array $variables: An associative array containing:

  • content: An array of content types.

See also

node_add_page()

File

core/modules/node/node.module, line 501
The core module that allows content to be submitted to the site.

Code

function template_preprocess_node_add_list(&$variables) {
  $variables['types'] = array();
  if (!empty($variables['content'])) {
    foreach ($variables['content'] as $type) {
      $variables['types'][$type->id()] = array(
        'type' => $type->id(),
        'add_link' => \Drupal::l($type->label(), new Url('node.add', array('node_type' => $type->id()))),
        'description' => array(
          '#markup' => $type->getDescription(),
        ),
      );
    }
  }
}
doc_Drupal
2016-10-29 09:46:46
Comments
Leave a Comment

Please login to continue.