0

How can i change the default title of back-end pages. On which block / page file i need to edit. I am new Magento, so if you could explain it from scratch , it would be a great help. Thanks in advance.

1

This can be done via xml. You will need to create an admin theme first.

How to create admin theme for Magento2

This will help you initally set up the theme ready to make a few changes to layouts.

Then find the location of the xml for for that page. This can normally be done by looking at the admin url.

Catalog Product Grid Example

For the url admin/catalog/product/index the original file for layout could be found within /vendor/magento/module-catalog/view/adminhtml/catalog_product_index.xml. I used the first part of the url to determine the module. Then looked within view/adminhtml folder for layout files for this module. The file should match the url like above from after your adminpath, so catalog/product/index will be catalog_product_view.xml.

This file should be left alone however can be overridden within your new admin theme. Create the following file:

app/code/design/adminhtml/vendor/admintheme/Magento_Catalog/view/template/catalog_product_view.xml

This will be different for each module in this example module-catalog is overidden by files within Magento_Catalog in your custom admin theme and module-sales-inventory would be Magento_SalesInventory.

So to change the title for this page add this xml to your custom catalog_product_view.xml within new theme:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="page.title">
  <action method="setPageTitle">
    <argument translate="true" name="title" xsi:type="string">New Title</argument>
 </action>
</referenceBlock>
</body>
</page>

Depending on which mode your in you may need to flush cache, deploy static content ect. Your changes should then be live on your site.

0

You can change the title via your block with this function:

public function _prepareLayout()
{
   //set page title
   $this->pageConfig->getTitle()->set(__('New title'));

   return parent::_prepareLayout();
}  

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.