cancel
Showing results for 
Search instead for 
Did you mean: 

Proper way to get $block->getChildHtml inside the custom phtml file

Proper way to get $block->getChildHtml inside the custom phtml file

I want to add default wishlist sidebar section into my Magento_Theme template,

Layout xml file:

 

<referenceBlock name="header.panel">

			<block class="Magento\Framework\View\Element\Template" name="mylocation.block" template="Magento_Theme::location_link.phtml" after="-">

			  <!-- Wishlist sidebar section -->
			<block class="Magento\Wishlist\Block\Customer\Sidebar" name="wishlist_sidebar" as="wishlist" template="Magento_Wishlist::sidebar.phtml"/> 

			</block>

		</referenceBlock>

 

FYI : The following code coming from core vendor\magento\module-wishlist\view\frontend\templates\sidebar.phtml

  <!-- Wishlist sidebar section -->
<block class="Magento\Wishlist\Block\Customer\Sidebar" name="wishlist_sidebar" as="wishlist" template="Magento_Wishlist::sidebar.phtml"/> 

After added in layout xml file and getting this block using getChildHtml in app\desigh\frontend\Zero\my_theme\Magento_Theme\templates\location_link.phtml

<?php echo $block->getChildHtml('wishlist');?>

Not working, any help thanks.