Drupal - Replace the home page

2020-07-20 03:57发布

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

Thanks you

标签: drupal
2条回答
萌系小妹纸
2楼-- · 2020-07-20 04:16

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.

查看更多
霸刀☆藐视天下
3楼-- · 2020-07-20 04:26

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.

查看更多
登录 后发表回答