04.07.2019 Views

frontend-developer-1

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Create and Customize Template Files<br />

Admin:<br />

Stores > Settings > Configuration > Advanced > Developer > Debug > Enabled<br />

Template Path Hints for Admin > Yes<br />

The next step is to look through the Magento code. The template is often set in<br />

layout XML, so this is the best place to start. Locate the block that renders the<br />

template in XML and see if the template is set. If so, it will contain the reference to<br />

the template. In some places, though, the template is defined in the PHP class itself.<br />

If this is the case, open the block class and look for the $_template property or<br />

some place where it is set.<br />

HELPFUL LINKS:<br />

• https://magento.stackexchange.com/a/173221/13<br />

4.3 DESCRIBE CONVENTIONS USED IN<br />

TEMPLATE FILES<br />

What conventions are used in PHP templates?<br />

• $this no longer applies to the rendering block. Use $block or $block-<br />

>getData('view_model') to obtain access to the instigating object or its<br />

data.<br />

• Always type hint variables that are automatically imported ($block,<br />

$viewModel).<br />

• Never use squiggly braces: this is a code smell that indicates your block or<br />

view model should be doing more work.<br />

Copyright © 2018, SwiftOtter, Inc.<br />

51

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!