Updated: Comment #N

Problem/Motivation

Core doesn't provide template suggestions based on a node's display mode. Having template overrides based on the display mode/view mode is an 80% use case. For example: http://drupal.stackexchange.com/questions/27974/drupal-7-template-sugges...

Proposed resolution

Add these template suggestions in node_theme_suggestions_node().

Remaining tasks

Patch
Patch review

User interface changes

n/a

API changes

n/a

Files: 
CommentFileSizeAuthor
#1 2228479-1.patch581 bytesCottser
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Setup environment: Test cancelled by admin prior to completion. View

Comments

Cottser’s picture

Status: Active » Needs review
FileSize
581 bytes
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Setup environment: Test cancelled by admin prior to completion. View

Before:

<!-- THEME DEBUG -->
<!-- CALL: _theme('node') -->
<!-- FILE NAME SUGGESTIONS:
   * node--1.html.twig
   * node--article.html.twig
   x node.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/bartik/templates/node.html.twig' -->

After:

<!-- THEME DEBUG -->
<!-- CALL: _theme('node') -->
<!-- FILE NAME SUGGESTIONS:
   * node--1.html.twig
   * node--article--full.html.twig
   * node--full.html.twig
   * node--article.html.twig
   x node.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/bartik/templates/node.html.twig' -->

The ordering is definitely up for debate, I can see maybe swapping --article and --full. Note that twig_debug output shows the suggestions from most specific to least specific.

Cottser’s picture

Status: Needs review » Closed (duplicate)

Status: Closed (duplicate) » Needs work

The last submitted patch, 1: 2228479-1.patch, failed testing.

Cottser’s picture

Status: Needs work » Closed (duplicate)