Drupal 8 fetch content and serve without header/footer

有些话、适合烂在心里 提交于 2019-12-06 15:09:18

This is an old question but it's coming up in searches and I wanted to post a solution. If you want to serve just some custom HTML include the Symfony HTML response class and call return a Response object. This will output only the HTML you provide.

use Symfony\Component\HttpFoundation\Response;

Class YourController extends ControllerBase {
  public function pageFunction() {
    return new Response('<html><div>test</div></html>');
  }
}

You can make a custom page, and in admin/structure/block you remove the blocks from header and footer from that url.

Or you make a custom page template and you remove the print of the header and footer.

File nameing: node--[content-type].html.twig ex: node--article.html.twig node--[content-type]--[display-format].html.twig, ex: node--article--full.html.twig

https://www.drupal.org/node/2282025

Hope I was helpful, please ask if you need further details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!