Skip to main content
added 367 characters in body
Source Link
Lauren G
  • 384
  • 2
  • 10

You can use a preprocess function to add a theme suggestion specifically for this view.

Something like:

function rodekors_theme_suggestions_container_alter(array &$suggestions, array $variables) {
  // addsince "if"kint() statement/ heredpm() toaren't checkworking, foruse somea valuejs uniqueconsole.log
 to yourecho view
"<script>console.log( 'Debug Objects: " . $variables['element']['#name'] $suggestions[]. ="' 'suggested_template';);</script>";

  if($variables['element']['#name'] = 'view_name') { // endvalue "if"from statementconsole.log
    $suggestions[] = 'suggested_template';
  }
}

Note: The above function is re-worked to function without dpm / kint, as OP had an unrelated debugging error. Usually, the echo "<script..."; code would be replaced with a standard Drupal debug function.

Then you can copy the standard container template file, rename it 'suggested-template', and just remove the outermost wrapping div.

Because that views-element-container is a container around the view, you need to access / alter the code on the container level, instead of the view level. Most likely, even if your unset theme-wrappers code worked, the div would still exist, just without its class.

You can use a preprocess function to add a theme suggestion specifically for this view.

Something like:

function rodekors_theme_suggestions_container_alter(array &$suggestions, array $variables) {
  // add "if" statement here to check for some value unique to your view
      $suggestions[] = 'suggested_template';
  // end "if" statement
}

Then you can copy the standard container template file, rename it 'suggested-template', and just remove the outermost wrapping div.

Because that views-element-container is a container around the view, you need to access / alter the code on the container level, instead of the view level. Most likely, even if your unset theme-wrappers code worked, the div would still exist, just without its class.

You can use a preprocess function to add a theme suggestion specifically for this view.

Something like:

function rodekors_theme_suggestions_container_alter(array &$suggestions, array $variables) {
  // since kint() / dpm() aren't working, use a js console.log
  echo "<script>console.log( 'Debug Objects: " . $variables['element']['#name'] . "' );</script>";

  if($variables['element']['#name'] = 'view_name') { // value from console.log
    $suggestions[] = 'suggested_template';
  }
}

Note: The above function is re-worked to function without dpm / kint, as OP had an unrelated debugging error. Usually, the echo "<script..."; code would be replaced with a standard Drupal debug function.

Then you can copy the standard container template file, rename it 'suggested-template', and just remove the outermost wrapping div.

Because that views-element-container is a container around the view, you need to access / alter the code on the container level, instead of the view level. Most likely, even if your unset theme-wrappers code worked, the div would still exist, just without its class.

Source Link
Lauren G
  • 384
  • 2
  • 10

You can use a preprocess function to add a theme suggestion specifically for this view.

Something like:

function rodekors_theme_suggestions_container_alter(array &$suggestions, array $variables) {
  // add "if" statement here to check for some value unique to your view
      $suggestions[] = 'suggested_template';
  // end "if" statement
}

Then you can copy the standard container template file, rename it 'suggested-template', and just remove the outermost wrapping div.

Because that views-element-container is a container around the view, you need to access / alter the code on the container level, instead of the view level. Most likely, even if your unset theme-wrappers code worked, the div would still exist, just without its class.