Create an admin page from template I want to create a completely bespoke admin page for some custom functionality. I don't want to hack the concept into render arrays as it will get messy fast.

I've got a menu declaration with a callback function, in here I can include and render templates. Using buffer streams, however, this only renders the file i'm passing. 

Is it possible and if so how, to extend Drupal's default admin layout (header/footer/scripts/css) and print my 'template' in where $page would normally go?

I know I could view source and copy the code required, but I feel that would be an awful approach so please don't suggest.



Attempted solution not working.

function MYMODULENAME_menu() {
    $items = array (
        'admin/content/xxx' =&gt; array(
            'title' =&gt; 'xxx',
            'page callback' =&gt; 'MYMODULENAME_timetable_admin',
            'access arguments' =&gt; array('access content'),
        )
    );

    return $items;
}


function xxx_theme() {
  return array(
    'funky_admin_page_content' =&gt; array(
      'variables' =&gt; array(),
    ),
  );
}

function xxx_funky_admin_page_content() {
    echo "hello world";
  return 'hello world';
}


function MYMODULENAME_timetable_admin() {
  return array(
    '#theme' =&gt; 'xxx',
  );
}


Hello world isn't found in view-source. So I can only gather that the function isn't firing. I've cleared caches several times. Am I missing something obvious?
Absolutely, it's quite straightforward.

You'll need a path for the page:

function MYMODULE_menu() {
  $items['admin/foo/bar'] = [
    'title' =&gt; 'Foo',
    'page callback' =&gt; 'MYMODULE_admin_page_callback',
    'access arguments' =&gt; ['whatever makes sense'],
  ];

  return $items;
}


A theme declaration:

function MYMODULE_theme() {
  return [
    'funky_admin_page_content' =&gt; [
      'variables' =&gt; [],
    ],
  ];
}


Your function to build/get the content. Note that you could also put this in a template file, see hook_theme() for more details.

function theme_funky_admin_page_content() {
  // Build your HTML, return it as a string.
}


And your page callback:

function MYMODULE_admin_page_callback() {
  return [
    '#theme' =&gt; 'funky_admin_page_content',
  ];
}