cancel
Showing results for 
Search instead for 
Did you mean: 

Splash page in magento for two website instead to load home page

Splash page in magento for two website instead to load home page

Hello,

 

I have made two website in magento 

 

http://example.com and http://example.com/kids

 

Now i want a page where i will display on these two website name only and once customer click on the link then it will redirect on respective website.

 

How can i achieve this. Please guide me.

 

Thanks in advance.

 

Regards, J

1 REPLY 1

Re: Splash page in magento for two website instead to load home page

You can use event "controller_action_predispatch" and check condition to show splash page. 

 

<controller_action_predispatch>
        <observers>
          <magebuzz_splash_controller_action_predispatch>
            <type>singleton</type>
            <class>splashpage/observer</class>
            <method>showSplashPage</method>
          </magebuzz_splash_controller_action_predispatch>
        </observers>
      </controller_action_predispatch>

To make it work, you can use cookie to save website that customers want to view. If cookie is existed, show the website, otherwise, it will show splash page. In Observer, you can try this code: 

 

 

public function showSplashPage($observer) {
$cookie = Mage::getModel('core/cookie')->get('selected_website');
if ($cookie && $cookie != '') {
return $this;    
}

//here the code is to redirect to splash page, you need to redirect only if current page is not splash page (write condition yourself)
Mage::app()->getResponse()->setRedirect($redirectUrl);
			Mage::app()->getResponse()->sendResponse();
			exit;
}

Finally, in the splash page, you need to get 2 websites and show 2 buttons. Once button is clicked, you get value and save in Cookie. You can save it by Javascript. Here is an example: 

 

 

<script type="text/javascript">
var cookieExpiry = 'expiry time';
var cookieName = 'selected_website';
var redirectBeforeSplashUrl = 'your website url';
 Event.observe('enter-website-button', 'click', function (e) {					
					var exdate = new Date();
					exdate.setDate(exdate.getDate() + cookieExpiry);
					var cookieValue = escape('splashpage') + "; expires="+exdate.toUTCString();
					document.cookie= cookieName + "=" + cookieValue;
					location.href = redirectBeforeSplashUrl;
				});
</script>

 

Hope this helps!