1

This is my etc/adminhtml/menu.xml

<add id="My_Module::first" title="I Am Parent" module="My_Module" sortOrder="1" parent="My_Module::parent" resource="My_Module::first" />

<add id="My_Module::firstchild" title="first child" module="My_Module" sortOrder="1"  action="" parent="My_Module::first" resource="My_Module::firstchild"/>
<add id="My_Module::secondchild" title="second child" module="My_Module" sortOrder="2"  action="" parent="My_Module::first" resource="My_Module::secondchild"/>
<add id="My_Module::thirdchild" title="third child" module="My_Module" sortOrder="3"  action="module/route/index" parent="My_Module::first" resource="My_Module::thirdchild"/>

Now I want to change title for the thirdchild menu item,
so i did this from index controller of thirdchild

index.php

public function execute(){
    $this->resultPage = $this->resultPageFactory->create();  
    $this->resultPage->setActiveMenu('My_Module::first');
    $this->resultPage->getConfig()->getTitle()->set((__('I Am Third Child')));
    return $this->resultPage;
}

But it always comes with its parent title I Am Parent.

I also try to change title from module_route_index.xml like below,

<head>
 <title>I Am Third Child</title>
</head>

But it also dont works, is there any solution i can try further.

Thanks

3

Try prepend(__("My Title"));

public function execute()
{
    $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->prepend(__("My Title"));
        return $resultPage;
}
  • Working Perfectly. Thankx – Rizwan Khan Mar 6 '18 at 9:13

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.