Question

I'm trying to make a magento splash page. As a test, I'm making it so that you just enter your favorite color, set it as a cookie. If the cookie is set, you see the default home page, otherwise it directs you to a page where it asks you for your favorite color. I've already made the code to set the cookie.

I just need to route the default homepage to my own controller, which will test whether or not the cookie is set. Then redirect accordingly the pertinent part of config.xml looks like this:

<frontend>
    <routers>
        <favoritecolor_2>
            <use>standard</use>
            <args>
                <module>MyNameSpace_FavoriteColor</module>
                <frontName></frontName>
            </args>
        </favoritecolor_2>
    </routers>  
</frontend>

I have tried several values for the <frontname> but it is always ignored. My controller is never called.

What should go in <frontname> for this to work, or is this even the correct way to accomplish this? Would it work better to use a Magento routing event? It's really not too important if the cookie is set, just a design request. I'm OK if clients go straight to other pages without the cookie being set.

Was it helpful?

Solution

The routers node is not quite how you'd want to go about this. The settings in this configuration node are how an individual module (like Mage_Catalog) tells the system it wants to handle URLs for a particular "front name" (like catalog in http://store.example.com/catalog/view/index`).

Fortunately, the functionality you're after is already built into Magento. If you navigate to

System -> Configuration -> Default Pages

The "Default Web URL" lets you set a custom URL to use for Magento's homepage. In most systems this is set to cms, which is why the URL

http://store.example.com/cms

is a duplicate of the homepage. Just set this to the URL for your custom controller, and you'll be all set.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top