0

I did now know the xml and its layout rendering. I want to change the positions of the blocks in the wishlist xml.

Here is the file wishlist_index_index. And here is the block

 <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info" name="customer.wishlist.item.name" template="item/column/name.phtml" cacheable="false"/>
 <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Comment" name="customer.wishlist.item.comment" template="item/column/comment.phtml" cacheable="false">
 <arguments>
   <argument name="title" translate="true" xsi:type="string">Product Details and Comment</argument>
 </arguments>
 </block>

These are two different blocks now i want to wrap them inside a div ? when they appear in the html side. How can i achieve this?

1

Create a container and place both blocks in it

<container name="custom.container" htmlTag="div" htmlClass="your_class" after="-">

        <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info" name="customer.wishlist.item.name" template="item/column/name.phtml" cacheable="false"/>

                <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Comment" name="customer.wishlist.item.comment" template="item/column/comment.phtml" cacheable="false">
                    <arguments>
                        <argument name="title" translate="true" xsi:type="string">Product Details and Comment</argument>
                    </arguments>

        </block>
</container>

or move these block in the required container, like

 <move element="customer.wishlist.item.name" destination="custom.container" before="-" />
 <move element="customer.wishlist.item.comment" destination="custom.container" after="customer.wishlist.item.name" />
  • I have wrap it in container but the name and comment box is now not showing. – tech_geek Oct 3 '17 at 9:52
  • these are child blocks, you can start a <div> in item/column/name.phtml and close in item/column/comment.phtml. This in not a good approach but it will work – Waqar Oct 3 '17 at 10:37
  • is it a good approach or it is a hack? i mean if i really want to make a block of div there? – tech_geek Oct 3 '17 at 10:38
  • it is a hack, but will not create any issue – Waqar Oct 3 '17 at 10:40
0
<block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info" name="customer.wishlist.item.name" template="item/column/name.phtml" cacheable="false">

                <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Comment" name="customer.wishlist.item.comment" as="customer.wishlist.item.comment" template="item/column/comment.phtml" cacheable="false">
                    <arguments>
                        <argument name="title" translate="true" xsi:type="string">Product Details and Comment</argument>
                    </arguments>
                </block>
</block> <!-- close your block here -->

Now in your name.phtml start your div tag with your content and at the end of content of item.phtml just call

<?php echo $block->getChildHtml('customer.wishlist.item.comment'); ?>

and end your div tag after this line

  • these are parallel blocks not one block inside another block. – tech_geek Oct 3 '17 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.