Using Macros

After importing Macros in Netbeans, you can use it for following cases:1. Text/Label Translation: When you are using label/text in template(.phtml) files, it is always recommended to wrap up label/text string as:

<?php echo $this->__('Label or Text goes here...') ?>

in order to make it multi-lingual friendly.

In order to use Macro for this case: Select the label/text which you want to translate and press: [Alt] + T. This shortcut will auto prepend: <?php echo $this->__(‘ and append: ‘) ?> code for you and hence reducing the no of codes. Isn’t that cool?

2. Output PHP Variables: In order to output variable in template file, you need to add php opening & closing tags which makes a simple echo code a bit lengthier. For example:

<?php echo $someVariable ?>

In order to use Macro for this case: Select the variable which you want to echo and press: [Alt] + E. It will auto prepend: <?php echo and append: ?> code for you.

In order to use Macro for this case: Select the div block which you want to comment and press: [Alt] + C. It will auto prepend: <?php /* and append: */ ?> and hence div block content will be commented out.

These were some Tips & Tricks on using Netbeans Macros effectively in order to reduce the amount of code and making your Magento templating life bit easier. I request my beloved readers to share their favorite Macros which can help others to automate the coding to some extent.