diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 2353be3..4734205 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -158,16 +158,20 @@ function node_theme() { 'node_add_list' => array( 'variables' => array('content' => NULL), 'file' => 'node.pages.inc', + 'template' => 'node-add-list', ), 'node_preview' => array( 'variables' => array('node' => NULL), 'file' => 'node.pages.inc', + 'template' => 'node-preview', ), 'node_recent_block' => array( 'variables' => array('nodes' => NULL), + 'template' => 'node-recent-block', ), 'node_recent_content' => array( 'variables' => array('node' => NULL), + 'template' => 'node-recent-content', ), 'node_edit_form' => array( 'render element' => 'form', @@ -1371,27 +1375,27 @@ function node_get_recent($number = 10) { } /** - * Returns HTML for a list of recent content. + * Prepares variables for list of recent content templates. * - * @param $variables + * Default template: node-recent-block.html.twig. + * + * @param array $variables * An associative array containing: * - nodes: An array of recent node entities. * * @ingroup themeable */ -function theme_node_recent_block($variables) { +function template_preprocess_node_recent_block(&$variables) { $rows = array(); - $output = ''; $l_options = array('query' => drupal_get_destination()); foreach ($variables['nodes'] as $node) { $row = array(); - $node_recent_content = array( - '#theme' => 'node_recent_content', - '#node' => $node, - ); $row[] = array( - 'data' => drupal_render($node_recent_content), + 'data' => array( + '#theme' => 'node_recent_content', + '#node' => $node, + ), 'class' => 'title-author', ); if (node_access('update', $node)) { @@ -1410,52 +1414,41 @@ function theme_node_recent_block($variables) { } if ($rows) { - $table = array( + $variables['table'] = array( '#theme' => 'table', '#rows' => $rows, ); - $output = drupal_render($table); if (user_access('access content overview')) { - $more_link = array( + $variables['more_link'] = array( '#theme' => 'more_link', '#url' => 'admin/content', '#title' => t('Show more content'), ); - $output .= drupal_render($more_link); } } - - return $output; } /** - * Returns HTML for a recent node to be displayed in the recent content block. + * Prepares variables for recently created node templates. + * + * Default template: node-recent-content.twig. * - * @param $variable + * @param array $variables * An associative array containing: * - node: A node entity. - * - * @ingroup themeable */ -function theme_node_recent_content($variables) { +function template_preprocess_node_recent_content(&$variables) { $node = $variables['node']; - $output = '
' . t('You have not created any content types yet. Go to the content type creation page to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '
'; } - return $output; } @@ -143,41 +139,36 @@ function node_preview(NodeInterface $node) { } /** - * Returns HTML for a node preview for display during node creation and editing. + * Prepares variables for node preview templates. * - * @param $variables + * Default template: node-preview.html.twig. + * + * @param array $variables * An associative array containing: * - node: The node entity which is being previewed. * * @see NodeFormController::preview() * @see node_preview() - * - * @ingroup themeable */ -function theme_node_preview($variables) { +function template_preprocess_node_preview(&$variables) { $node = $variables['node']; - $output = ''; - - $elements = node_view($node, 'teaser'); - $elements['#attached']['library'][] = array('node', 'drupal.node.preview'); - $trimmed = drupal_render($elements); - $elements = node_view($node, 'full'); - $full = drupal_render($elements); - - // Do we need to preview trimmed version of post as well as full version? - if ($trimmed != $full) { - drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication. You can insert the delimiter "<!--break-->" (without the quotes) to fine-tune where your post gets split.')); - $output .= '{{ 'You have not created any content types yet. Go to the content type creation page to add a new content type.'|t({'@create-content': url('admin/structure/types/add')}) }}
+{% endif %} diff --git a/core/modules/node/templates/node-preview.html.twig b/core/modules/node/templates/node-preview.html.twig new file mode 100644 index 0000000..1bc3441 --- /dev/null +++ b/core/modules/node/templates/node-preview.html.twig @@ -0,0 +1,23 @@ +{# +/** + * @file + * Default theme implementation for a node preview. + * + * This display may be used during node creation and editing. + * + * Available variables: + * - preview_teaser: Flag indicating whether to show a trimmed teaser version. + * - teaser: Trimmed teaser version of the node. + * - full: Full version of the node. + * + * @see template_preprocess_node_preview() + * + * @ingroup themeable + */ +#} +{% if preview_teaser %} +