Magento 配置弹出窗口 - html 文件应该放在模块层次结构中的哪里?
在我的模块配置中,我有一个按钮。单击该按钮时,我会弹出一个窗口,收集更多输入。该文件只是一个 html 文件,但它应该位于模块的目录结构中的哪里?
为了提供更多信息 - 只是为了查看一些工作,我定义了我的字段,如下所示:
<button_url_test_window_open><![CDATA[/px.html]]></button_url_test_window_open>
<frontend_model>mymodule/adminhtml_system_config_testWindowOpenDialog</frontend_model>
并将 px.html 文件放在我的 htdocs/magento 文件夹中。当我单击该按钮时,它会打开 /px.html,但这似乎不对。我不知道如何表达这个问题,但我觉得我应该做一些更像“为 mymodule 打开名为 px.html 的文件”的事情,然后 magento 会在正确的位置查找。抱歉,关于术语,我仍在掌握 Magento/PHP/Apache。
为了完成我目前所拥有的图片,frontend_model 块是:
protected function _prepareLayout()
{
parent::_prepareLayout();
if (!$this->getTemplate()) {
$this->setTemplate('mypackage/system/config/test_window_open_dialog.phtml');
}
return $this;
}
public function render(Varien_Data_Form_Element_Abstract $element)
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$originalData = $element->getOriginalData();
$this->addData(array(
'button_label_test_window_open' => Mage::helper('mymodule')->__($originalData['button_label_test_window_open']),
'button_url_test_window_open' => $originalData['button_url_test_window_open'],
'html_id' => $element->getHtmlId(),
));
return $this->_toHtml();
}
test_window_open_dialog.phtml 文件包含:
<table>
<tr>
<td>
<button style="" onclick="javascript:window.open('<?php echo $this->getButtonUrlTestWindowOpen()?>', 'testing','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=100, top=100, width=600, height=470'); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>">
<span><?php echo $this->escapeHtml($this->getButtonLabelTestWindowOpen()); ?></span>
</button>
</td>
</tr>
</table>
In my module config, I have a button. When that button is clicked I pop up a window that gathers some more input. That file is just an html file, but where should it live in the directory structure of the module?
To give a bit more info - just to see something working, I defined my field as follows:
<button_url_test_window_open><![CDATA[/px.html]]></button_url_test_window_open>
<frontend_model>mymodule/adminhtml_system_config_testWindowOpenDialog</frontend_model>
and I put the px.html file in my htdocs/magento folder. When I click the button it results in /px.html being opened, but that doesn't seem right. I'm not sure how to word the question, but I feel I should be doing something more like 'open the file called px.html for mymodule' and magento would then look in the right place. Sorry about the terminology, I'm still getting to grips with Magento/PHP/Apache.
Just to complete the picture of what I currently have, the frontend_model block is:
protected function _prepareLayout()
{
parent::_prepareLayout();
if (!$this->getTemplate()) {
$this->setTemplate('mypackage/system/config/test_window_open_dialog.phtml');
}
return $this;
}
public function render(Varien_Data_Form_Element_Abstract $element)
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$originalData = $element->getOriginalData();
$this->addData(array(
'button_label_test_window_open' => Mage::helper('mymodule')->__($originalData['button_label_test_window_open']),
'button_url_test_window_open' => $originalData['button_url_test_window_open'],
'html_id' => $element->getHtmlId(),
));
return $this->_toHtml();
}
and the test_window_open_dialog.phtml file contains:
<table>
<tr>
<td>
<button style="" onclick="javascript:window.open('<?php echo $this->getButtonUrlTestWindowOpen()?>', 'testing','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=100, top=100, width=600, height=470'); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>">
<span><?php echo $this->escapeHtml($this->getButtonLabelTestWindowOpen()); ?></span>
</button>
</td>
</tr>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
phtml 文件不会进入模块目录中的任何位置。模块目录包含您的块、助手、模型、控制器、Sql 安装/升级文件以及配置 xml 文件。模板文件位于 app/design/adminhtml(如果是管理模板)中,或者位于 app/design/frontend(如果将在网站前端使用)中。
phtml files don't go anywhere within your module directory. Module directories house your Blocks, Helpers, Models, Controllers, Sql installation/upgrade files, and your configuration xml files. Template files go in either app/design/adminhtml (if it is an admin template), or in app/design/frontend if it will be used on the frontend of the site.