Magento Theme validation

Overview

Validate use of local.xml in custom templates, no excessive file overwriting in template. Validate prober theme inheritance. Validate proper use of JS and CSS includes. Avoid having to much logic in template, and loading objects from templates.

Templates

  • Use “_” symbol as a word separator in .phtml file names. I.e.: price_msrp_item.phtml All other separators like “-” or CamelCaseFormat are not allowed.
  • Short tags (<? ?> , <?= ?>) in .phtml files are not allowed.
  • Retrieving collection in .phtml files is not allowed (and models as well, especially with load method calls)
  • Connected code (neither <!– nor /*, // ) is not allowed
  • Debug conditions like var_dump, print_r, Zend_Debug::dump(), exit or die are not allowed
  • Each .phtml file must have PHPDOC with the current class name:

/**

* @var $this Mage_Authorizenet_Block_Directpost_Iframe

*/

or 

/**

* @see Mage_Authorizenet_Block_Directpost_Form

*/

  • “return” statements in .phtml files are not allowed
  • Complex PHP logic is not allowed in .phtml files
  • All calls in .phtml file must to public functions i.e.: <?php $this->getProductName() instead of $this->_getProductName()
  • Use alternative syntax for if/for/foreach/while and other statements. I.e. <?php if (….): > <?php endif ?> instead of <?php if (….) { … } ?>
  • Inline css/js is not allowed in .phtml files

Layouts

  • Copypaste of the core layout files is not allowed (I.e. re-declaration of catalog.xml or page.xml in the custom theme)
  • All js/css files must be included only via layout file. Otherwise it’s not possible o merge them.
  • Use proper theme inheritance
  • Avoid using local.xml is possible. Each module should have own layout update file.
  • Block name in layout file must be separated by dots. I.e.: <reference name=”product.info.options.wrapper”>

Translations

  • Each module has own translation file.
  • Use Translator.translate() for JS translations
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s