0

I have a module named some_module.

This is my some_module.routing.yml:

some_module.index:
 path: '/this/is/the/path'
 defaults:
   _title: 'Some Title'
   _controller: '\Drupal\some_module\Controller\SomeController::index'
 requirements:
   _permission: 'access content'

This is my SomeController.php:

namespace Drupal\some_module\Controller;

use Drupal\Core\Controller\ControllerBase;

class SomeController extends ControllerBase {
    public function index()
    {
        return [
            '#theme' => 'some_template',
          ];
    }

When I go to /this/is/the/path in my browser. It's showing my theme's header and footer. How can I customize header and footer when I access /this/is/the/path?

1 Answer 1

1

It depends on how you have built these. Generally you will set any blocks in the header and footer to only show on the paths they are meant to show on, in the block visibility settings. If you need completely different headers and footers altogether, you can build a new theme with those headers and footers, and create a custom theme negotiator (https://www.webomelette.com/choose-your-theme-dynamically-drupal-8-theme-negotiation) to set the theme for those pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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