23.02.2015 Views

www.it-ebooks.info

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Frontend Development<br />

Let's break down the configuration code we just added:<br />

• : Previously, we added all the configuration inside the global<br />

scope; since we want our routes to be only available in the frontend, we need<br />

to declare our custom routes under the frontend scope<br />

• : This is the container tag that holds the configuration for our<br />

custom routes<br />

• : The naming convention for this tag is to match the<br />

module name and is the unique identifier for our route<br />

• : As we learned in Chapter 2, Magento Fundamentals for<br />

Developers, Magento breaks down the URLs into http://localhost.com /<br />

frontName/actionControllerName/actionMethod/.<br />

Once we have defined our route configuration, we need to create an actual controller<br />

to handle all the incoming requests.<br />

The index controller<br />

Our first step is to create IndexController under our module controllers directory.<br />

Magento will always try to load IndexController if no controller name is specified.<br />

The file location is app/code/local/Mdg/Giftregistry/controllers/Index.php.<br />

Refer to the following code:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!