1

I need to modify a block class called in a phtml file, this is the customer.phtml file:

<?php
// @codingStandardsIgnoreFile

?>
<?php if($block->customerLoggedIn()): ?>
    <li class="customer-welcome">
        <span class="customer-name"
              role="link"
              tabindex="0"
              data-mage-init='{"dropdown":{}}'
              data-toggle="dropdown"
              data-trigger-keypress-button="true"
              data-bind="scope: 'customer'">
            <span data-bind="text: customer().fullname"></span>
            <button type="button"
                    class="action switch"
                    tabindex="-1"
                    data-action="customer-menu-toggle">
                <span><?php /* @escapeNotVerified */ echo __('Change')?></span>
            </button>
        </span>
        <script type="text/x-magento-init">
        {
            "*": {
                "Magento_Ui/js/core/app": {
                    "components": {
                        "customer": {
                            "component": "Magento_Customer/js/view/customer"
                        }
                    }
                }
            }
        }
        </script>
        <?php if($block->getChildHtml()):?>
       <div class="customer-menu" data-target="dropdown">
            <?php echo **$block->getChildHtml()**;?>
       </div>
        <?php endif; ?>
    </li>
<?php endif; ?>

I'm interested in the block beetween the div with class customer-menu. I want to remove <ul class="header link"> tag but not their li children, this ul tag is inside the <ul class="header link"> when someone is logged in.

3
  • Can you specify what actually you want to remove? Commented May 15, 2019 at 10:33
  • You want to remove the ul class based on customer login/logout action?
    – aravind
    Commented May 15, 2019 at 10:44
  • The ul tag when a customer is logged in, when it is not logged in the block is not loaded. what is the class of $block->getChildHtml()?
    – blob
    Commented May 15, 2019 at 10:49

1 Answer 1

0

You can check the Customer Block Class in:

Magento\Customer\Block\Account\Customer.php

2
  • There is no getChildHtml() method.
    – blob
    Commented May 15, 2019 at 11:51
  • I think that method is a reserve magento method used to get child block of the parent block
    – fmsthird
    Commented May 15, 2019 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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