Вопрос

I'd like to set the title and add some scripts in the default Magento Contact page . So in my theme's directory I have added the following file:

Magento_Contact/layout/contact_index_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="cms_page_layout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>Contact1</title>
        <script src="https://....."/>
    </head>
</page>

which is not working. Am I missing something here?

--------------------------------UPDATE-------------------------------------

It seems that many pages have the same issue in my website. Many product pages (not all of them) and some other pages have head title "Create New Customer Account". I have no idea where this comes from and why it affects these pages like that. Any method tested in order to set the head title in these page fails.

Это было полезно?

Решение 4

The answer to this is some kind of bug with meta title. It seems that head title gets it value from page/product Meta Title. If Meta Title is empty, page/product gets head title as "Create New Customer Account".

I filled all Meta Titles in order to view correct titles in my pages, but I don't know where this bug comes from.

Другие советы

you can try this :

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
layout="1column"xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <head>
      <title>Contact1</title>
      <css src="css/local-l.css"/>
  </head>
</page>

Run php bin/magento setup:upgrade.

Create the file contact_index_index.xml in theme folder app/design/frontend/Vendor/theme/Magento_Contact/layout

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>Your title</title>
        <script src="https://...." src_type="url"/>
    </head>
</page>

For Title try this:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="cms_page_layout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>

        <script src="https://....."/>
    </head>
    <body> 
        <referenceBlock name="page.main.title">
            <action method="setPageTitle">
                <argument translate="true" name="title" xsi:type="string">Add Your Title</argument>
            </action>
        </referenceBlock>
    </body> 

</page>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top