Make a custom HTML page in Drupal without file access or custom templates
There are times when you need to throw up a simple landing page for a website that really doesn't conform to the standard page structure that is already in place. Take something like this:
This is a simple landing page from a direct mail campaign that gives the intended audience a quick run down and then forwards them on to a more detailed info page or a registration form. Since the main website runs on Drupal, we could either upload a index.html file and all of its images into a "/stlouiscup" folder (or throw it in a sub-folder and use mod_rewrite to get the user the full URL from a shortcut) or we could use the Drupal interface to give us the ability to create a completely custom HTML page at a custom URL, and to upload images and any other files it may need (like a JavaScript library!) directly to this page. The method below will work in any version of Drupal.
"Custom Page" content type
- Create a new content type called "Custom Page", with only the "Title" and "Body" fields.
- Enable file attachments for this content type.
- If you're using CKEditor or another WYSIWYG editor for page bodies, be sure to disable it for this content type.
- If you'd like, you can set PHP Code to be the default text format for this body field, or at least something that won't try and alter your custom markup.

- Create a single new .tpl file in your theme's templates folder called:
- Drupal 6:
page-custom-page.tpl.php - Drupal 7:
page--custom-page.tpl.php
with the following contents:
-
<?php print $node->content['body']['#value']; ?>
- Drupal 6:
When you create a new custom_page node via the standard Drupal interface, this page will be rendered (themed) without any of your typical output, only your raw body will appear. You can use the file attachments to quickly upload any images or files you need and reference their uploaded paths right in your code. This takes the leg work out of needing to gain file access just to make a new custom page, and is especially helpful on sites where code versioning is being used and the time required to create a new custom page is much greater than simply coding the page itself.


Comments
how to make a website
Thanks Charlie;
Nice post regarding making html page.
Add new comment