Book Image

Magento PHP Developer????s Guide, 2nd Edition

By : Allan MacGregor
Book Image

Magento PHP Developer????s Guide, 2nd Edition

By: Allan MacGregor

Overview of this book

Table of Contents (16 chapters)
Magento PHP Developer's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Blocks and layouts


As we learned in Chapter 2, ORM and Data Collections, Magento separates its view layer into blocks, templates, and layout files. Blocks are objects that handle part of the logic. Templates are .phtml files that are a mix of HTML and PHP code. Layout files are XML files that control the position of the blocks.

Each module has its own layout file that is in charge of updating that specific module layout. We need to start by creating a layout file for our module:

  1. Navigate to app/design/frontend/base/default/layout/.

  2. Create a file named mdg_giftregistry.xml.

  3. Add the following code located at app/design/frontend/base/default/layout/mdg_giftregistry.xml:

    <layout version="0.1.0">
      <mdg_giftregistry_index_index>
      </mdg_giftregistry_index_index>
    
      <mdg_giftregistry_index_new>
      </mdg_giftregistry_index_new>
    
      <mdg_giftregistry_index_edit>
      </mdg_giftregistry_index_edit>
    
      <mdg_giftregistry_view_view>
      </mdg_giftregistry_view_view...