您好我从http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/custom_module_with_custom_database_table下载了模块创建者。 我在我的网站上添加了这个。它的工作正常,但问题是我想为此制作一个tempale页面。我不想在这里使用网格。 我怎样才能做到这一点。虽然我在xml页面中添加了模板页面。我已经创建了模板页面。但是有空白页面显示。我怎样才能解决这个问题。
答案 0 :(得分:2)
执行您要执行的操作的两个步骤:
(请注意小写和大写)
1-更新adminhtml Block类
在类声明中更改:
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创建的代码,文件和文件夹现已过时。
我最好的选择是从头开始创建自己的模块:)