Charles Yeung
Charles Yeung

Reputation: 38803

Drupal - Replace the home page

Hi Anyway to stop people browsing the Drupal home page and redirect to my specific html page?

Thanks you

Upvotes: 3

Views: 6221

Answers (2)

soulston
soulston

Reputation: 147

For Drupal 7 you need to use page--front.tpl.php

If your theme doesn't have a page.tpl.php that you can copy, then copy it from your base theme if you are using one or:

modules/system/page.tpl.php

This should be placed in your custom theme folder in (assuming this is not a multisite):

sites/all/themes/my_theme

I tend to structure my themes as follows:

my_theme.info
templates/html.tpl.php
templates/page/page--front.tpl.php
templates/node/node.tpl.php
templates/block/block.tpl.php
css/style.css

But it doesn't really matter where it is, it will be picked up after a cache clear.

Upvotes: 5

Ran Bar-Zik
Ran Bar-Zik

Reputation: 1237

If you have specific HTML page that it is on the server and doesn't generated from Drupal, the most easy way is to use Drupal goto.

How to do it? open your template.php and search for page_preprocess function it should look like that:

YOURTHEME_preprocess(&$variables, $hook) {
  if( drupal_is_front_page()) {
      drupal_goto('yoursite.com/yourpage.html')
  }
}

change YOURTHEME to your theme name and clear the cache.

The real Question why should you use static HTML file for your homepage? I would create some article or view for homepage and change it as I like with theming... It is much easier than any other alternative.

Upvotes: 3

Related Questions