You are here

function template_preprocess_multi_node_add_list in Multi Node Add 8

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

./multi_node_add.module, line 36
Allows to create multiple nodes using one page, one form submission.

Code

function template_preprocess_multi_node_add_list(array &$variables) {
  $variables['types'] = [];
  if (!empty($variables['content'])) {
    foreach ($variables['content'] as $type) {
      $variables['types'][$type
        ->getOriginalId()] = [
        'type' => $type
          ->getOriginalId(),
        'add_link' => Link::createFromRoute($type
          ->label(), 'multi_node_add.add', [
          'node_type' => $type
            ->getOriginalId(),
        ]),
        'description' => [
          '#markup' => $type
            ->get('description'),
        ],
      ];
    }
  }
}