Book Image

Magento PHP Developer's Guide

By : Allan MacGregor
Book Image

Magento PHP Developer's Guide

By: Allan MacGregor

Overview of this book

<p>Magento has completely reshaped the face of e-commerce since its launch in 2008. Its revolutionary focus on object oriented and EAV design patterns has allowed it to become the preferred tool for developers and retailers alike.</p> <p>"Magento PHP Developer’s Guide" is a complete reference to Magento, allowing developers to understand its fundamental concepts, and get them developing and testing Magento code.</p> <p>The book starts by building the reader’s knowledge of Magento, providing them with the information, techniques, and tools that they require to start their first Magento development.</p> <p>After building this knowledge, the book will then look at more advanced topics: how to test your code, how to extend the frontend and backend, and deploying and distributing custom modules.</p> <p>"Magento PHP Developer’s Guide" will help you navigate your way around your first Magento developments, helping you to avoid all of the most common headaches new developers face when first getting started.</p>
Table of Contents (16 chapters)
Magento PHP Developer's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Block and layouts


As we learned in Chapter 2, Magento Fundamentals for Developers, Magento separates its view layer into blocks, templates, and layout files. Blocks are objects that handle parts 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 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 by following these steps:

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

  2. Create a file named mdg_giftregistry.xml.

  3. Add the following code (the file location is 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...