I'm still pretty new to Drupal. I needed help creating a blank page template for a certain content type. When I say blank, I mean the only thing thats displayed on the page is the render($page['content']) information. None of the markup that is added with the html.tpl.php template.

To give you a wider perspective of what I'm trying to accomplish - I'm trying to use the assets that are housed here in an .ajax request to display elsewhere.

Thanks for your time.


5 Answers 5


Personally I deal with situations like this in a custom module by registering a path with a callback function that prints the needed content:

function mymodule_menu() {
  $items['somepage/%'] = array(
    'title' => 'Somepage',
    'page callback' => 'mymodule_ajax_callback',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  return $items;

function mymodule_ajax_callback($nid) {
  if ($node = node_load($nid)) {
    $view = node_view($node, 'full');
    print drupal_render($view);

This would get you the view of node 12 without any external markup on 'somepage/12' for example. Note that when you use return instead of print you get the page with additional markup added (just for future reference).

If you want to go with the template approach you could create 2 templates: 'html--blank.tpl.php' and 'page--blank.tpl.php'. The first one should contain only <?php print $page; ?> and the second <?php print render($page['content']); ?>. In your template.php file add:

function mytheme_preprocess_html(&$variables) {
  if (isset($variables['page']['content']['system_main']['nodes'])) {
    $nodes = $variables['page']['content']['system_main']['nodes'];
    $key = key($nodes);
    if (count($nodes) == 2 && $nodes[$key]['#node']->type == 'my_content_type') {
      $variables['theme_hook_suggestions'] = array('html__blank');

function mytheme_preprocess_page(&$variables) {
  if (isset($variables['node']) && $variables['node']->type == 'my_content_type') {
    $variables['theme_hook_suggestions'] = array('page__blank');

These solutions will give you a slightly different result, but either should get the job done (just remember to modify them to fit your needs and clear the caches).

  • how is it that you call this php function from the javascript?
    – skribbz14
    Commented May 21, 2016 at 16:26
  • @skribbz14 I'm not fully sure what you mean, but javascript isn't involved here (all the example code is in php).
    – Madis
    Commented May 25, 2016 at 12:42

You can change the suggestions that Drupal uses on the fly, and I do believe it's possible to create a suggestion so that Drupal will load an appropriately named html.tpl.php file based on a number of factors. You need to elaborate more on the requirements of your AJAX request... for example, is it a specific content type that your AJAX will be rendering out?

Also if you're using content generated by Drupal to display elsewhere you should look into using the Services module as it sounds like it does exactly what you need it to do, based on what you've written so far.


The way that core modules do this type of thing is to provide a delivery callback for menu items defined in hook_menu(). You could work a little bit of logic in a custom module to do it for node pages of a certain type:

function MYMODULE_menu_alter(&$items) {
  // Override the page delivery callback for the node view page.
  $items['node/%']['delivery callback'] = 'MYMODULE_deliver_node_page';

function MYMODULE_deliver_node_page($page_callback_result) {
  // This function will only ever be called for a node view page
  // so we can safely assume menu_get_object() will provide a valid node
  $node = menu_get_object();

  // Check you're on the right type of node page
  if ($node->type == 'content_type') {
    // Set any headers you need, e.g.
    drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');

    // Output just the content that lives in the system_main block.
    echo render($page_callback_result['content']['system_main']);
  else {
    // Default to the standard drupal_deliver_html_page()

I don't think that's possible in Drupal in the way you're going about it. When it comes to blanking out the base markup provided by html.tpl.php, node.tpl.php, etc. the only solution that comes to mind is to actually blank out the aforementioned files, which unfortunately would apply to your entire theme.

What I'd image you'd need to do is that you'd have to introduce your own small custom module that handled the AJAX requests, then you have full control over the output that's being sent back to your AJAX handler.


Have you tried suggestions? For the particular content type.

  • Yes I've tried that. Unfortunately still no luck. Commented Feb 1, 2012 at 20:59

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.