Time for action – removing a block from the right column

Most of Magento's pages have either two or three columns, with the right column containing information such as the shopping cart contents and a product comparison block. We will be removing one of these; the technique shown can be used for removing most unwanted blocks from the frontend of your store.

  1. Turning on Template Path Hints and block names: As mentioned we'll pick removing the "product compare" block from the right column of Magento for our example:
    Time for action – removing a block from the right column

    To find out where to look we have to know what kind of block we are dealing with. Template Path Hints can be turned on for that purpose, with the additional option to display "block names". In the following screenshot you can see how the frontend of your store will look after activating these:

    Time for action – removing a block from the right column
  2. Finding the block and layout update file to edit: As you can see in the screenshot, the compare block is of type catalog/product_compare_sidebar. The first bit, catalog, is what we are interested in.
  3. Finding the section for the compare block inside the layout update file: In the layout folder we can now open the catalog.xml file.
    Time for action – removing a block from the right column

    In this file we can see a section called default, which contains a section that says <reference name=right>. In this <reference name=right> part are all the blocks that should be displayed in the right column according to catalog.xml. It's possible that other layout update files also add blocks to the right column by referencing the right column! For example, the checkout.xml file also uses <reference name=right> to add the shopping cart sidebar to the right column.

  4. Removing the compare block from the layout file: After this search, removing the product compare block is easy. Remove the line that starts with <block type="catalog/product_compare_sidebar" and save the file. The result should look like the following screenshot:
    Time for action – removing a block from the right column

    The product compare block will now be gone when you click on through your store!

Note

Magento uses a method of quickly remembering some of your settings called caching. After you have made changes to the design configuration or layout update files, it may be necessary to go to System | Cache Management and clear all the caches. You do this by selecting all the checkboxes (clicking on Select All also works), then selecting Refresh from the drop-down menu in the top-right and clicking on the Submit button. When you are working on your store, it is often handy to choose Disable from the drop-down menu instead, so you don't have to refresh the caches after every change. Remember to re-enable caches when you are done!

It should have become apparent by now that making adjustments to Magento themes should not be underestimated. We advise you to make a careful consideration between spending your time on your store's content or on messing with themes. Often calling in the services of an expert helps free your time for all the other essential e-commerce activities.

What just happened?

The app/design/frontend/beginner/guide/layout folder shown in the following screenshot contains XML files that tell Magento what information to show where. All the XML files define blocks, and the frontend of your store is always constructed by composing multiple small blocks together into one big page. The blocks to load for a certain section of the website are defined in the XML files. In other words, which HTML files Magento should show is determined in those files. Explaining all the intricacies of the XML structure is outside of the scope of this book. For that we point to Magento's theming guide, which was previously mentioned.

What just happened?

In the layout folder shown in the preceding screenshot, you'll see that the XML files are named according to Magento components such as customer, catalog, and checkout. Every frontend component in Magento has its own logic and you can often use that to find the relevant XML file quickly as well. For instance, if you want to edit the shopping cart sidebar block that is shown in the right column of the store, the checkout.xml file is a logical place to look even without having to turn on Template Path Hints and accompanying block names!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset