Setting up our routes

Now that we are capable of saving and manipulating the data by using our models, we need to provide a way for customers to interact with the actual gift registries. Our first step is to need to create valid routes or URLs for the frontend.

As are many things in Magento, this is controlled by the configuration file. A route will convert a URL into a valid controller, action, and method.

Open our config.xml file and insert the following code, located at app/code/local/Mdg/Giftregistry/etc/config.xml:

<config>

  <frontend>
    <routers>
      <mdg_giftregistry>
        <use>standard</use>
        <args>
          <module>Mdg_Giftregistry</module>
          <frontName>giftregistry</frontName>
        </args>
      </mdg_giftregistry>
    </routers>
  </frontend>

</config>

Let's break down the configuration ...

Get Magento PHP Developer's Guide - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.