Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal - Replace the home page

Tags:

drupal

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

Thanks you

like image 645
Charles Yeung Avatar asked Dec 02 '25 21:12

Charles Yeung


2 Answers

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.

like image 111
soulston Avatar answered Dec 06 '25 17:12

soulston


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.

like image 45
Ran Bar-Zik Avatar answered Dec 06 '25 17:12

Ran Bar-Zik