The header row on a diff view page is difficult to alter without making URL checks in a preprocess function (brittle) or overriding theme_table's output (overkill).

It would be nice to have a method of altering the header text without needing to jump through so many hoops. Proposed approach to this to follow.

CommentFileSizeAuthor
#1 1955610-1-diff-header_alter.patch992 byteselliotttf

Comments

elliotttf’s picture

Status: Active » Needs review
StatusFileSize
new992 bytes
alan d.’s picture

I thought that this was fairly trivial

function THEME_table__diff__standard($variables) {
  // modify whatever for the diff standard comparison view only
  if (isset($variables['header'])) {
    unset($variables['header']);
  }
  return theme('table', $variables);

  # Or chain to a common modification for all diff tables via
  return theme('table__diff', $variables);
}

So you use the above code with

THEME_table($variables); // Bad, you have to replicate everything
THEME_table__diff($variables); // Good, but not targeted exactly.
THEME_table__diff__standard($variables); // Better if you only want this table header modified
THEME_table__diff__preview($variables); // Better if you only want this table header modified
alan d.’s picture

Status: Needs review » Closed (works as designed)

Closing due to lack of feedback and the existing solution works nicely afaict.

Complain to sun if the __ syntax is confusing, I think he spearheaded this during D7 development from memory ;)

jwilson3’s picture

Version: 7.x-3.x-dev » 8.x-1.x-dev
Category: Feature request » Support request
Issue summary: View changes
Status: Closed (works as designed) » Active

How can the theming output be done in Drupal 8? I need to add a <div class="container"> around the diff-header, navigation, and controls, but not affect the original node content (which already has a container wrapper).

It is not immediately obvious to a themer how to do this.

I've looked at adding logic in the template where the output is rendered (block--system-main-content.html.twig) but by this point in the render pipeline the {{ content }} object has already been rendered to markup, so its impossible to isolate the diff-related UI elements as a separate renderable array element.

adamjuran’s picture

I have the same issue as @jwilson3, wanting to wrap the output in other markup. Is there a reason there is no twig template for this module? Could there be?