0

I have a sub theme with the parent theme being the bootstrap theme. I am able to configure the site branding block to show up on my content type pages and that's because my sub theme has a hook which suggests this full--width--page template. This full--width--page template has the {{page.branding}} region in it and it works fine.

However it wont appear on the contact page or the user login page? I suspect the boostrap theme or parent drupal engine uses the regular page.html.twig template for contact page and user login page and other pages. the {{page.branding}} does not seem to work in the page.thml.twig template.

I am looking for possible solutions. Maybe I ened a hook to tell the theme to use the full--width--page.twig template but I don't know how to write that hook, or maybe I ened to find out what is wrong witht he page--html.twig template.

Any help would be appreciated.

0

You can probably override the suggestions using hook_theme_suggestions_page_alter in your THEMENAME.theme file

function THEMENAME_theme_suggestions_page_alter(array &$suggestions, array $variables) {

  //the routes to use the specified template
  $use_template = [
    "user.register", // user/register
    "user.login", // user/login
    "user.pass", // user/password
    "entity.contact_form.canonical", // core contact form (website feedback)
    "entity.webform.canonical", // all webforms will have this route
  ];

  // what route are we on ?   
  $route_name = \Drupal::routeMatch()->getRouteName();

  if (in_array($route_name, $use_template) ){
    $suggestions[] = 'full__width__page';
  }
}

You should clear the cache and your specific template should take control.

If you have twig debugging enabled and your browser has show html comments enabled you should see something similar to this the page source

<!-- FILE NAME SUGGESTIONS:
   X full--width--page.html.twig
   * page--user--register.html.twig
   * page--user.html.twig
   * page.html.twig
-->

With x indicating the twig template responsible for the particular output. In this case full--width--page.html.twig is the twig template used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.