3

In view file what does this stand for :

<?= $block->getChildHtml('', true) ?> 

From where this get the child html

5
  • it means render all child block HTML. Commented Aug 29, 2018 at 13:03
  • there is lot of child block , then which one block is render? Commented Aug 29, 2018 at 13:05
  • it will render all children block whihc are under the current block For Ex. product.info.addtocart Commented Aug 29, 2018 at 13:07
  • 1
    this line of code in this path vendor/magento/module-catalog/view/frontend/templates/product/view/options/wrapper.phtml so which block is render ,, can you explain it ? Commented Aug 29, 2018 at 13:07
  • I have explained it as answer. Commented Aug 29, 2018 at 13:20

1 Answer 1

3

As we can see product.info.options.wrapper have two children in catalog_product_view.xml

 <block class="Magento\Catalog\Block\Product\View" name="product.info.options.wrapper" as="product_options_wrapper" template="Magento_Catalog::product/view/options/wrapper.phtml"> <block class="Magento\Catalog\Block\Product\View\Options" name="product.info.options" as="product_options" template="Magento_Catalog::product/view/options.phtml"> <block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" name="product.info.options.default" as="default" template="Magento_Catalog::product/view/options/type/default.phtml"/> <block class="Magento\Catalog\Block\Product\View\Options\Type\Text" name="product.info.options.text" as="text" template="Magento_Catalog::product/view/options/type/text.phtml"/> <block class="Magento\Catalog\Block\Product\View\Options\Type\File" name="product.info.options.file" as="file" template="Magento_Catalog::product/view/options/type/file.phtml"/> <block class="Magento\Catalog\Block\Product\View\Options\Type\Select" name="product.info.options.select" as="select" template="Magento_Catalog::product/view/options/type/select.phtml"/> <block class="Magento\Catalog\Block\Product\View\Options\Type\Date" name="product.info.options.date" as="date" template="Magento_Catalog::product/view/options/type/date.phtml"/> </block> <block class="Magento\Framework\View\Element\Html\Calendar" name="html_calendar" as="html_calendar" template="Magento_Theme::js/calendar.phtml"/> </block> 

in hte XML product.info.options.wrapper block have two children:

  1. product.info.options
  2. html_calendar

that's why they used <?= $block->getChildHtml('', true) ?> in product/view/options/wrapper.phtml file also we can add our custom option or block for more Options that's why they are rendering all child.

Even Magento adding some option for the bundle without overriding that PHTML file in /vendor/magento/module-bundle/view/frontend/layout/catalog_product_view_type_bundle.xml

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.