diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc index e838460..8aea2b7 100644 --- a/core/modules/node/content_types.inc +++ b/core/modules/node/content_types.inc @@ -75,7 +75,8 @@ function node_overview_types() { } /** - * Returns HTML for a node type description for the content type admin page. + * Preprocess variables for node-admin-overview.html.twig, a node type + * description for the content type admin page. * * @param $variables * An associative array containing: @@ -88,14 +89,10 @@ function node_overview_types() { * * @ingroup themeable */ -function theme_node_admin_overview($variables) { - $name = $variables['name']; - $type = $variables['type']; - - $output = check_plain($name); - $output .= ' ' . t('(Machine name: @type)', array('@type' => $type->type)) . ''; - $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; } @@ -157,7 +150,8 @@ function node_preview(Node $node) { } /** - * Returns HTML for a node preview for display during node creation and editing. + * Preprocess variables for node-preview.html.twig, a node preview for display + * during node creation and editing. * * @param $variables * An associative array containing: @@ -168,30 +162,26 @@ function node_preview(Node $node) { * * @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) { + // Render trimmed teaser version of the post. + $node_teaser = node_view(clone $node, 'teaser'); + $node_teaser['#attached']['library'][] = array('node', 'drupal.node.preview'); + $variables['teaser'] = $node_teaser; + // Render full version of the post. + $node_full = node_view($node, 'full'); + $variables['full'] = $node_full; + + // Do we need to preview a trimmed teaser version of a post as well as a full + // version? + if ($variables['teaser'] != $variables['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-admin-overview.html.twig b/core/modules/node/templates/node-admin-overview.html.twig new file mode 100644 index 0000000..7ea022b --- /dev/null +++ b/core/modules/node/templates/node-admin-overview.html.twig @@ -0,0 +1,19 @@ +{# +/** + * @file + * Default theme implementation for a node type description for the + * content type admin page. + * + * Available variables: + * - name: Human readable name of the content type. + * - machine_name: Machine readable name of the content type. + * - description: Description of the content type. + * + * @see template_preprocess() + * @see template_preprocess_node_admin_overview() + * + * @ingroup themeable + */ +#} +{{ name }} {{ '(Machine name: @type)'|t({'@type': machine_name}) }} +