How to Place a Block Inside Another Without getChildHtml() in Magento 2

blockslayout

I'm working on a loyalty module. For each order, i would like to show the number of loyalty points related to the it in the sales_order_view, just below the order_totals block, declared in the sales.xml layout.

The problem is that i can't modify or override core's templates to avoid any conflict with another module. Therefore, i can't add getChildHtml() to place my block.

Do you have any idea ?

Best Answer

You cannot do that for the block you want.
Here is why.
The template sales/order/view.phtml renders the order_items block through the line <?php echo $this->getChildHtml('order_items') ?>.
This one is rendered by the template sales/order/items.phtml.
This other one shows the order totals through <?php echo $this->getChildHtml('order_totals') ?>. the totals block is rendered by the template sales/order/totals.phtml. None of the templates mentioned above have a getChildHtml() call without any parameters nor do they allow a generic block where you can add a child block for rendering.