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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.