0

I need to create a completely blank page in Drupal. For simplicity sake the entire page should display the following:

<html>
    <body>
        <h2>Hello World!</h2>
    </body>
</html>

While I can normally just create a page outside of Drupal, this page will need to access some of Drupals functions such as db_query. How can I create a completely blank page for a single url (e.g. http://www.example.com/blankpage)?

1

2 Answers 2

0

I don't really advise this but here is a solution.

Create a php file in your Drupal root containing the following

<?php 
define('DRUPAL_ROOT', getcwd());
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
?>

That will give you access to the full Drupal api. You can then put whatever markup you wish underneath.

A better method (but more complicated) would be just to create a custom page callback in a module then you can use that to either bypass Drupals theming, or you can make it change the theme to a custom one that produces very basic markup (you'd have to create that yourself).

If you want any details on how to do that let me know :)

1
  • Thanks, I did the more complicated method and it seemed to work great.
    – John
    Commented Apr 27, 2014 at 11:16
0

If you are wanting to create a blank page in drupal you need to do the following steps:

1.) Create a theme

2.) Next step is to create a template.php file that will contain html and page preprocessing using theme_preprocess_html and theme_preprocess_page

3.) You will make your theme suggestions and route them to a custom html.tpl.php and page.tpl.php file. Normally these will be your themes page and html templates where you render regions and any other changes. But in your case you want it to be blank so you can provide your own markup. Note this is not advised and is NOT best practices in drupal.

Here is an example of the template.php file rendering page--logout.tpl.php and html--logout.tpl.php

Note the mytheme is the name of your theme and you are going to add your information to the theme_hook_suggestions array. Drupal finds the most specific or in this case I prepended it to the beginning using array_unshift

function MYTHEME_preprocess_page(&$variables){
  array_unshift($variables['theme_hook_suggestions'], "page__logout");
}

function MYTHEME_preprocess_html(&$variables){
  array_unshift($variables['theme_hook_suggestions'], "html__logout");
}

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.