سؤال

أحاول الكتابة فوق نموذج الاتصال لكنه غير قادر على التجاوز.ولهذا اتبعت الخطوات التالية.

الخطوة 1) app/code/Learning/Contact/composer.json

{
  "name": "learning/contact",
  "description": "contact",
  "require": {
      "php": "~5.5.0|~5.6.0|~7.0.0",
      "magento/framework": "100.0.*",
      "magento/module-ui": "100.0.*",
      "magento/module-config": "100.0.*"
  },
  "type": "magento2-module",
  "version": "1.0.0",
  "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
  "autoload": {
        "files": [
            "registration.php"
        ],
        "psr-4": {
            "Learning\\Contact\\": ""
        }
    }
}

الخطوة 2) app/code/Learning/Contact/registration.php

<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Learning_Contact',
    __DIR__
);

الخطوه 3) app/code/Learning/Contact/etc/module.xml

 <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Learning_Contact" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Contact"/>
        </sequence>
    </module>
</config>

الخطوة 4) app/code/Learning/Contact/view/frontend/layout/contact_index_index.xml

<?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>Contact Us</title>
    </head>
    <body>
        <referenceContainer name="content">
            <referenceBlock name="contactForm">
                <action method="setTemplate">
                    <argument name="template" translate="true" xsi:type="string">Learning_Contact::form.phtml</argument>
                </action>
            </referenceBlock>
        </referenceContainer>
    </body>
</page>

الخطوة 5) app/code/Learning/Contact/view/frontend/templates/form.phtml

<h1> Hi I'm here.... </h1>

الخطوة 6) مسح ذاكرة التخزين المؤقت

php bin/magento cache:clean

الخطوة 7) الوحدة النمطية الممكّنة

php bin/magento setup:upgrade

هل الخطوات المذكورة أعلاه صحيحة أم حدث خطأ ما؟

هل يمكن أن تعطيني الاتجاه الصحيح من فضلك؟

هل كانت مفيدة؟

المحلول

لك app/code/Learning/Contact/view/frontend/layout/contact_index_index.xml تم تكوينه بشكل خاطئ

قم بتغيير هذه الملفات إلى

<?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>Contact Us</title>
    </head>
    <body>
        <referenceBlock name="contactForm">
                <action method="setTemplate">
                    <argument name="template" translate="true" xsi:type="string">Learning_Contact::form.phtml</argument>
                </action>
         </referenceBlock>
    </body>
</page>

فقط قم بإزالة <referenceContainer name="content"> و </referenceContainer> منك contact_index_index.xml

لا تنس مسح ذاكرة التخزين المؤقت

نصائح أخرى

في اسم الملحن.json يجب أن يكون

learning/module-contact

لذلك، قم بتغيير الملحن.json الكود التالي

{
    "name": "learning/module-contact",
    "description": "contact",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0",
        "magento/framework": "100.0.*",
        "magento/module-ui": "100.0.*",
        "magento/module-config": "100.0.*",
        "magento/module-contact": "100.0.*"
    },
    "type": "magento2-module",
    "version": "100.0.0",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
        "files": [ "registration.php" ],
        "psr-4": {
            "Learning\\Contact\\": ""
        }
    }
}

امسح ذاكرة التخزين المؤقت وقم بتشغيل أمر الترقية مرة أخرى.

php bin/magento setup:upgrade

يمكنك أيضًا تعيين الرمز في عرض contact_index_index أدناه:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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>Contact Us</title>
    </head>
    <body>
        <referenceContainer name="content">
            <block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Krish_Contact::form.phtml">
                <container name="form.additional.info" label="Form Additional Info"/>
            </block>
        </referenceContainer>
    </body>
</page>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top