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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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(), ), ); } } } |
Please login to continue.