0

I've created a page layout using panels in the Drupal admin UI (page_machine_id). I'm trying to load that page into a custom controller like so and render one of the variants (Drupal 8):

public function profile() {
    $page = \Drupal\page_manager\Entity\Page::load('page_machine_id');
    $variants = $page->getVariants();
    $pageVariant = end($variants);
    $viewer = new \Drupal\page_manager\Entity\PageVariantViewBuilder();
    $pageArray = $viewer->view($pageVariant);
    return new Response(render($pageArray));
}

This renders the page content correctly, but does not include the theme wrapper around it and I can't figure out how to get the theme to show.

Thanks.

  • Just return $pageArray; should be enough – Clive Nov 22 '18 at 19:34
  • Thought I tired that but apparently not. Thanks! – iamamused Nov 22 '18 at 19:36
0

solution is

    return $pageArray;

Adding Response bypasses Drupals rendering.

  • Yes, you can return either a render array or a Symfony Response object. – Kevin Nov 23 '18 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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