【问题标题】:new page in backend in magentoMagento后端的新页面
【发布时间】:2011-01-30 21:43:28
【问题描述】:

嗨,我已经从http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/custom_module_with_custom_database_table 下载了模块创建器。 我已经在我的网站上添加了这个。它工作正常,但问题是我想为此制作一个寺庙页面。我不想在这个中使用网格。 我怎样才能做到这一点。虽然我在 xml 页面中添加了模板页面。我已经创建了模板页面。但是显示了空白页面。我该如何解决这个问题。

【问题讨论】:

标签: php magento


【解决方案1】:

两步做你想做的事:

(请注意大小写)

1- 更新 adminhtml Block 类

  • 打开 app/local/[YourNamespace]/[YourModule]/Block/Adminhtml/[YourModule]/Grid.php
  • 在类声明中改变:

    class [YourNamespace]_[YourModule]_Block_Adminhtml_[YourModule]_Grid extends Mage_Adminhtml_Block_Widget_Grid

    class [YourNamespace]_[YourModule]_Block_Adminhtml_[YourModule]_Grid extends Mage_Adminhtml_Block_Widget_Form_Container

  • 然后清除文件的所有内容(方法)并替换为:

    public function __construct() {
    parent::__construct();

    $this->setTemplate('[yourmodule]/[some-template-filename].phtml');

    $this->setId('[some_id]');
    

    }

2- 创建您的模板文件

创建 app/design/adminthml/default/default/template/[youmodule]/[some-template-filename].phtml 您会通过深入研究其他 Magento 模块来找到想法和灵感,但这里有一些起点:

<div class="content-header">
 <table cellspacing="0" class="grid-header">
  <tr>
   <td><h3><?php echo $this->__('A nice title'); ?></h3></td>
   <td class="a-right">
    <button onclick="history.go(-1)" class="scalable back" type="button"><span><?php echo $this->__('Cancel'); ?></span></button>
    <button onclick="editForm.submit()" class="scalable save" type="button"><span><?php echo $this->__('Save'); ?></span></button>
   </td>
  </tr>
 </table>
</div>
<div class="entry-edit">
 <form id="edit_form" name="edit_form" method="post" action="YOUR JOB TO CALL THE RIGHT CONTROLLER">
  <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
  <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Another nice title')?></h4>
  <fieldset id="my-fieldset">
   <table cellspacing="0" class="form-list">
    <tr>
     <td class="label"><?php echo $this->__('A nice TD title'); ?> <span class="required">*</span></td>
     <td class="label required-entry">
       CONTENT FOR YOUR TD
     </td>
    </tr>
   </table>
  </fieldset>
 </form>
</div>
<script type="text/javascript">
 var editForm = new varienForm('edit_form');
</script>

以上所有内容都应该指导您想要实现,但只要您不使用通常通过单击由 Module Creator 生成的“常规”网格的某行提供的项目编辑,一个完整的工作台Module Creator 创建的代码、文件和文件夹现已过时。

我最好的选择是从头开始制作自己的模块:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-30
    • 1970-01-01
    • 2022-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-23
    相关资源
    最近更新 更多