Shopping Cart

You have no items in your shopping cart.

30 days money back

We will refund to you if you want to return a product for any reason during 30 days after purchasing it. Read More...

6-month free support included

We guarantee free and fast support during the 6-month term after purchasing a product. Read More...

BUG FREE

If you find any bugs in our product during the support term, we will fix them for free. Read More...

Swipe to the right

Built in Magento block hightlighter

By Igor Goltsov August 22, 2011 1416 Views No comments

In this article, we discuss Magento, an open source e-commerce system. This framework is characterised by its functionality as well as by its difficulty. Everyone who ever tried to design programs for this framework is well aware that such programming is uneasy task that is, in fact, impossible to perform on the first try. It will take a week or two to create your first module, to design your first theme, or to fix something that needs to be fixed properly and in the right place. I would like to share a secret with you, a secret of completing all these tasks promptly and fair while using built-in procedures only.

These figures show the result of work with a built-in developer tool. Those who familiar with Magento know that themes for this framework are composed of template pieces. Also there's a distinct class behind every template piece, whether built-in or third-party developer class. Since some particular class of the active store may be overridden by extension modules, it may took vast amount of time to determine which block is responsible for preparation of the information to be displayed to the user, and which file in the theme is responsible for this or that part of the page.

Few users know that Magento can inform the user about which class and file are responsible for the area of interest on your page. To see this information you need to enter backend via System -> Config -> Developer tab -> Debug group. Once there, you need to activate options called "Template Path Hints" and "Add Block Names to Hints". The trick is that there is no such options available on this tab (or anywhere else) by default. To make these options appear, you have to open the following file:

app/code/core/Mage/Core/etc/system.xml

Search this file for the following string of code:

                        <template_hints translate="label">
<label>Template Path Hints</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>20</sort_order>
<show_in_default>0</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</template_hints>
<template_hints_blocks translate="label">
<label>Add Block Names to Hints</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>21</sort_order>
<show_in_default>0</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</template_hints_blocks>

And replace it with another piece of code:

                        <template_hints translate="label">
<label>Template Path Hints</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</template_hints>
<template_hints_blocks translate="label">
<label>Add Block Names to Hints</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>21</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</template_hints_blocks>

Once this is done, the named options will appear on the tab we've mentioned before. For those options, the <show_in_default> attribute was set as 0, what means they are never displayed. Now we allowed these options to appear. So switch them on and enjoy! This trick saved loads of my working hours which I could spend searching for the file I needed instead of coding.

Fortunately for support service staff and those who work with real stores this trick works there as well. Just don't forget to restrict the IP-addresses that have permission to browse debugging data (see figure below).

Results of this procedure are given below (see figure).

Posted in: Development