1

I've created a controller with the route "/get-info", the controller return a template custom-info.html.twig

my_module/src/Controller/MyController.php file:

<?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;

class MyController extends ControllerBase {

  public function content() {

    return [
      '#theme' => "custom_info",
    ];
  }
}

my_module/templates/custom-info.html.twig file:

<h1> Hello World </h1>

When visiting the path: www.mySite.com/get-info I get response with the header an footer of my site and "Hello World" as content. but when using <iframe src="www.mySite.com/get-info"></iframe> in an other Drupal project I get an empty iframe.

Is this the right way to create iFrame-ready Widgets in Drupal 8? if so what should I add/remove to make it work?

1

1 Answer 1

1

The problem was solved by installing and enabling Allow site iframing contrib module.

Drupal 8 has a feature built into core that stops the site from being rendered within an iframe, there are good reasons for this - https://www.drupal.org/node/2514136 But sometimes you want your site in an iframe, so that's what this module does.

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.