سؤال

لدي وحدة مخصصة مع ما يلي:

magento-project/app/code/local/Hunique/Customs/etc/config.xml

<?xml version="1.0" ?>
 <config>
<modules>
    <Hunique_Customs>
        <version>1.0.1</version>
    </Hunique_Customs>
</modules>

<global>
    <models>
        <custommodule>
            <class>Hunique_Customs_Model</class>
            <resourceModel>custommodule_resource</resourceModel>
        </custommodule>
        <custommodule_resource>
            <class>Hunique_Customs_Model_Resource</class>
            <entities>
                <custommodule>
                    <table>custommodule</table>
                </custommodule>
                <questions>
                    <table>questions</table>
                </questions>
                <answers>
                    <table>answers</table>
                </answers>
            </entities>
        </custommodule_resource>
    </models>

    <resources>
        <custommodule_setup>
            <setup>
                <module>Hunique_Customs</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </custommodule_setup>
        <custommodule_read>
            <connection>
                <use>core_read</use>
            </connection>
        </custommodule_read>
        <custommodule_write>
            <connection>
                <use>core_write</use>
            </connection>
        </custommodule_write>
    </resources>

    <blocks>
        <custommodule>
            <class>Hunique_Customs_Block</class>
        </custommodule>
    </blocks>

    <helpers>
        <hunique_customs>
            <class>Hunique_Customs_Helper</class>
        </hunique_customs>
    </helpers>

</global>

<frontend>
    <routers>
        <custommodule>
            <use>standard</use>
            <args>
                <module>Hunique_Customs</module>
                <frontName>custommodule</frontName>
            </args>
        </custommodule>
    </routers>

    <layout>
        <updates>
            <custommodule>
                <file>custommodule.xml</file>
            </custommodule>
        </updates>
    </layout>

</frontend>    
<admin>
    <routers>
        <adminhtml>
            <use>admin</use>
            <args>
                <modules>
                    <Hunique_Customs before="Mage_Adminhtml">Hunique_Customs</Hunique_Customs>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

<adminhtml>
    <layout>
        <updates>
            <custommodule>
                <file>custommodule.xml</file>
            </custommodule>
        </updates>
    </layout>
</adminhtml>

ثم لدي /magento-project/app/code/local/Hunique/Customs/etc/adminhtml.xml في نفس المجلد

<config>
<menu>
    <hunique>
        <title>Hunique</title>
        <sort_order>1</sort_order>
        <children>
            <customs_qa module="hunique_customs">
                <title>Questions And Answers</title>
                <sort_order>1</sort_order>
                <action>adminhtml/custommodule</action>
            </customs_qa>
        </children>
    </hunique>
</menu>

ثم في التصميم لدي:/magento-project/app/design/adminhtml/default/default/layout/custommodule.xml

<?xml version="1.0"?>
<layout>
  <adminhtml_custommodule_index>
    <reference name="content">
        <block type="core/template" output="toHtml" name="templateBlock" template="custommodule/questions-and-answers.phtml" />
    </reference>
   </adminhtml_custommodule_index>
 </layout>

ولدي ملف/magento- المشروع/التطبيق/التصميم/adminhtml/الافتراضي/الافتراضي/القوالب/custommule/QUESTOMS-and-Andwers.phtml ولكن هذا يحتوي فقط على علامة H1 مع اختبار فيه الآن.

لدي أيضا وحدة التحكم:/magento-project/app/code/local/Hunique/Customs/controllers/CustommoduleController.php

<?php
class Hunique_Customs_CustommoduleController extends Mage_Adminhtml_Controller_Action
{   
  public function indexAction()
  {    
    var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());
    $this->loadLayout();
    $this->renderLayout();
  }
}

لدي تفريغ var لمعرفة ما إذا كان لدي أي مقابض ولكن هذه مصفوفة فارغة.يتم تحميل صفحتي من قائمة الإدارة..enter image description hereتعمل مساراتي وقائمة الإدارة بشكل جيد، لكن لا يمكنني إظهار ملف phtml الخاص بي...أي شخص يمكن أن يوجهني في الاتجاه الصحيح؟

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

المحلول

يجب أن يعمل الرمز الذي قدمته كما هو.على الرغم من أن كلاً منكما config.xml و adminhtml.xml الملفات ليس لها <config> تم إغلاق العلامات، أظن أنك ارتكبت هذا الخطأ عند لصق التعليمات البرمجية هنا، وإلا فسترى خطأً بدلاً من صفحة ذات منطقة محتوى فارغة.

نصيحتي هي أنه يجب عليك البحث عن الأخطاء المطبعية في أسماء الملفات أو تداخل الدلائل الخاطئة.أيضا لديك var_dump فارغ، لأنك تحاول إظهار مقابض التخطيط قبل تحميل التخطيط فعليًا.يجب عليك تبديل السطرين الأولين في عملك:

public function indexAction() {  
    $this->loadLayout();
    var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());
    $this->renderLayout();
}

يمكنك أيضًا التأكد من أن لوحة الإدارة الخاصة بك تستخدم default/default package/theme أو أنه موجود في السلسلة الاحتياطية.إذا كان يستخدم حزمة أخرى (على سبيل المثال. custompackage/default)، فإنه لن ينظر في default/default.إذا لم تكن متأكدًا، فيمكنك دائمًا وضع ملف xml الخاص بتحديث التخطيط والقالب الخاص بك فيه base/default بدلاً من.إنه غير موجود في لوحة الإدارة، ولكن يمكنك إنشاؤه وسيتم استخدامه كإجراء احتياطي أخير.

اسمحوا لي أن أعرف إذا كان ذلك يساعد.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top