I want to output a google map div with a side panel in my drupal 8 moodule. So no need for blocks surrounding my main content.

The question is how do I tell Drupal to only render main content using a Twig template of my module without outputting the entire Drupal theme stuff a long with the menus and the blocks?

All online materials I found so far talks about concepts behind Drupal rendering mechanism and render arrays but none really tell something about their implementation.

Take for instance, the concept of page variants in the following link. HTMLRenderer fires an event to determine which type of page will be used to wrap the main content around: RenderEvents::SELECT_PAGE_DISPLAY_VARIANT. Its also says the SimplePageVariant, which will only output the main content, is suppose to be used by default but in case the Block module is enabled like my case, the BlockPageVariant kicks in to allow the placement of blocks in the regions around the main content. It continues, if you want, you can subscribe to this event in your own module and provide your own variant. However, I couldn't figure out how to do this subscribing.

How to tell Drupal 8 to disable the BlockPageVariant and only use the SimplePageVariant? What does it have to do with RenderEvents::SELECT_PAGE_DISPLAY_VARIANT?

I feel what I want is simpler than creating my own Page variant. I just want to output simple html with two divs in the Twig template of my own module.

Anyone has an idea what to do?

Comments

Sam Moore’s picture

I think the simplest Drupal-like way would in fact be to create a specific page.html.twig for your page. Then you could just delete or comment out the regions you don't want.

moqbel’s picture

Thanks for replying Sam,
I have dont what you suggested but im not really sure if i have done it right. i followed drupal 8 naming convention check this linkThe link doest explicitly state where would you put the override twig file. Mine is providers--html.twig.
I have put in my module template folder to override page.html.twig of bartic theme and it works fine. However, when I build the render array in the controller and return it so i can output it in my twig file that overrides the page.html.twig template, none of the variables get passed to my twig except the title which renders automatically. I dont understand! is there anything that im doing wrong here?

Sam Moore’s picture