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.
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?
So there are two ways to do this as mentioned in the answer below, I will just summarize them and add a little more clarification of naming convention in drupal 8:
Return a basic Symfony response with out any drupal specific rendering:
$element['#title'] = 'Title'; $html = \Drupal::service('renderer')->renderRoot($element); $response = new Response(); $response->setContent($html); return $response;
Doing so, you will not be able to attach css or js libraries with render arrays. However, if you want to do that you can override the page.html.twig by following dupral 8 template naming conventions link with out returning "pure symfony" response and hindering drupal from finishing its theming.