1

How do I redirect the users who want to visit my site to a PHP page that has a link to index.php?

When someone go to example.com they should see a PHP page (e.g. a welcome page) where they would find a link to access the front page.

5 Answers 5

0

Modules

You could accomplish this with the Rules module and add granular control over who sees the splash page and when.

Additional Details

Create a new rule. (admin/config/workflow/rules/reaction/add)

React on Event: Drupal is initializing

Condition: Execute Custom PHP Code

$homepage = FALSE;
if (drupal_is_front_page()) {
  $homepage = TRUE;
}
return $homepage;

Action: Page Redirect

Drupal Rules Exported Rule

This can be copy and pasted into the Rules Import menu. (admin/config/workflow/rules/reaction/import)

{ "rules_show_splash_page" : {
    "LABEL" : "Show Splash Page",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "splashpage" ],
    "REQUIRES" : [ "php", "rules" ],
    "ON" : [ "init" ],
    "IF" : [
      { "php_eval" : { "code" : "$homepage = FALSE;\r\nif (drupal_is_front_page()) {\r\n  $homepage = TRUE;\r\n}\r\nreturn $homepage;" } }
    ],
    "DO" : [ { "redirect" : { "url" : "splash-page-url" } } ]
  }
}

Tested and working on my dev site.

1
  • thank you too, i tried your way but it's the same, it's redirect to the splah page everu time visitor go to home page of my site. i just want to redirect once when open the site for the first time Commented Jun 15, 2012 at 7:06
2

If you're happy to go down the module route, the following should get you started.

You're going to want to set a cookie to see if the user has been to the site before. If the cookie is set, then you know the user has been to your site ebfore and it shouldn't redirect to the splash page.

function MYMODULE_init() {
  if (!isset($_COOKIE['mysite_firstvisit'])) {
    drupal_goto('path/to/splash/page');
    setcookie('mysite_firstvisit', '1');
  }
}
1

This project is in alpha, but the Splashify project may be what you're looking for.

3
  • i can't install this module in my site because it's incompatible with version 7.x-1.0 Commented Jun 15, 2012 at 19:05
  • What version of Drupal are you running?
    – Citricguy
    Commented Jun 16, 2012 at 0:19
  • drupal version 7.14 Commented Jun 17, 2012 at 9:47
0

I think you're talking about a Splash Screen (or "splash page").

I only know of one module that has such functionality for Drupal 7 (there was the Splash module for Drupal 6 but it hasn't been ported), and that's ThemeKey. One of the features that you can apparently "easily achieve" is:

a front-page / "splash" screen

5
  • i installed the modules but i did not knwo how to make it, can you put me in the right way? Commented Jun 14, 2012 at 21:06
  • Both of the modules you list link to the Splash project page... the actual link to ThemeKey is here.
    – EmmyS
    Commented Jun 14, 2012 at 21:08
  • Help for ThemeKey (once installed) is at /admin/help/themekey. There's a decent screencast at MustardSeed, although I don't know if it covers splash screens.
    – EmmyS
    Commented Jun 14, 2012 at 21:11
  • @abd See the link from EmmyS
    – Clive
    Commented Jun 14, 2012 at 21:14
  • thank you guys for your help, but what i want exactly is redirect to the splash page just for the first time the visitor ask my site, then it should go back to the original home page when click on the logo of mysite. Commented Jun 15, 2012 at 7:05
0

I added a page--front.tpl.php in my theme. Drupal picks that up as a splash screen.

1

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.