Docs
Partials
Partials
Zermatt allows to extract parts of templates into smaller, reusable pieces.
Open these files from the /vendor/maddlen/module-zermatt-examples/view/frontend directory:
templates/partials.phtmltemplates/partials/partial.phtmltemplates/partials/child-partial.phtml
In templates/partials.phtml
- We call the same partial twice, but with different data.
- The second call passes a
sub_prefixdata item
In templates/partials/partial.phtml
- In the
<h4>tag, we use thenamepassed from the parenttemplates/partials.phtml. - If the parent passed the
sub_prefixdata item, call a new partial where the template file starts with thesub_prefixvalue.
In templates/partials/child-partial.phtml
- This template name matches the rule from its parent partial
templates/partials/partial.phtml. - We display the
namevalue which was passed all along fromtemplates/partials.phtml.