Php Magento 1.6将选项卡添加到后端的客户编辑
我一直在尝试在Magento CE 1.6中向客户信息页面添加选项卡 我试过以下例子:Php Magento 1.6将选项卡添加到后端的客户编辑,php,magento,backend,magento-1.6,Php,Magento,Backend,Magento 1.6,我一直在尝试在Magento CE 1.6中向客户信息页面添加选项卡 我试过以下例子: 在mydons.com上 关于nextbits.eu 在ankursphp.blogspot.com上 最后一个似乎是唯一接近的。然而,它有两个问题。一是它编辑核心文件,二是当我点击标签时,它会旋转和染色。Chrome开发工具显示服务器报告404 谁能给我提供一些与Magento 1.6兼容的文档或代码 编辑添加最后一个链接中的文本,因为这似乎是唯一一个远程工作的链接 覆盖文件/app/code/cor
- 在mydons.com上
- 关于nextbits.eu
- 在ankursphp.blogspot.com上
编辑添加最后一个链接中的文本,因为这似乎是唯一一个远程工作的链接
/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php
,在\u beforeToHtml()方法中,添加以下代码:
$this->addTab('Custom',array(
'label' =>Mage::helper('customer')->__('Custom'),
'class' => 'ajax',
'url' => $this->getUrl('*/*/custom',array('_current'=>true)),
));
public function customAction()
{ $this->_initCustomer();
$this->getResponse()->setBody(
Mage::app()->getLayout()->createBlock('core/template')->setTemplate('custom/customer/tab/custom.phtml')->setCustomerId(Mage::registry('current_customer')->getId())
->setUseAjax(true)->toHtml()
);
}
/app/code/core/Namespace/ModuleName/Block/Adminhtml/Customer/Edit/Tab/
并创建Custom.php
,将以下源代码添加到文件中:
<?php
class Custom_Custom_Block_Adminhtml_Customer_Edit_Tab_Custom extends Mage_Adminhtml_Block_Widget_Form
{
public function __construct()
{
parent::__construct();
$this->setTemplate('custom/customer/tab/custom.phtml');
}
}
?>
/app/design/adminhtml/default/default/template/modulename/customer/tab/
并创建custom.phtml
<config>
...
<global>
...
<blocks>
<namespace_module>
<class>Namespace_Module_Block</class>
</namespace_module>
</blocks>
...
</global>
...
<adminhtml>
...
<layout>
<updates>
<namespace_module>
<file>namespace/module.xml</file>
</namespace_module>
</updates>
</layout>
...
</adminhtml>
...
</config>
设法追踪一些开箱即用的代码,这些代码无需任何修改即可作为起点: app/etc/modules/Russellalbin_Customertab.xml
<?xml version="1.0"?>
<config>
<modules>
<Russellalbin_Customertab>
<active>true</active>
<codePool>local</codePool>
</Russellalbin_Customertab>
</modules>
</config>
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_customer_edit>
<reference name="customer_edit_tabs">
<action method="addTab">
<name>customer_edit_tab_action</name>
<block>customertab/adminhtml_customer_edit_tab_action</block>
</action>
</reference>
</adminhtml_customer_edit>
</layout>
app/code/local/Russellalbin/Customertab/controllers/Adminhtml/CustomertabController.php
class Russellalbin_Customertab_Adminhtml_CustomertabController extends Mage_Adminhtml_Controller_Action
{
function resetAction()
{
$params = array();
$path = 'customer';
$customer_id = (int)$this->getRequest()->getParam('customer_id');
if($customer_id)
{
// Do your stuff here
$params['id'] = $customer_id;
$params['back'] = 'edit';
$params['tab'] = 'customer_edit_tab_action';
$path = 'adminhtml/customer/edit/';
}
$params['_store'] = Mage::getModel('core/store')->load(0);
$url = Mage::getModel('adminhtml/url')->getUrl($path, $params);
Mage::app()
->getResponse()
->setRedirect($url);
Mage::app()
->getResponse()
->sendResponse();
exit;
}
}
app/design/adminhtml/default/default/layout/customertab.xml
<?xml version="1.0"?>
<config>
<modules>
<Russellalbin_Customertab>
<active>true</active>
<codePool>local</codePool>
</Russellalbin_Customertab>
</modules>
</config>
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_customer_edit>
<reference name="customer_edit_tabs">
<action method="addTab">
<name>customer_edit_tab_action</name>
<block>customertab/adminhtml_customer_edit_tab_action</block>
</action>
</reference>
</adminhtml_customer_edit>
</layout>
客户\编辑\选项卡\操作
customertab/adminhtml\u客户\u编辑\u选项卡\u操作
app/design/adminhtml/default/default/template/customertab/action.phtml
<div id="customer_info_tabs_customer_edit_tab_action_content">
<div class="entry-edit">
<div class="entry-edit-head">
<h4 class="icon-head head-edit-form fieldset-legend">Pull List</h4>
</div>
<div id="group_fields4" class="fieldset fieldset-wide">
<div class="hor-scroll">
<h2>This is my form and content that I can submit and return back to this page and tab</h2>
<div><form action="<?php echo $this->getUrl('adminhtml/customertab/reset/', array('customer_id'=> $customer_id)); ?>" method="get"><input type="submit" value="Post This Form" /></form></div>
</div>
</div>
</div>
</div>
拉名单
这是我的表单和内容,我可以提交并返回到此页面和选项卡
您可以添加更多关于您尝试的内容的信息吗?如果链接断开,没有人可以访问它。添加第三个链接的信息-添加其他两个链接将使三个链接都无法读取。感谢您的帮助。这是获得要显示的选项卡的最低代码吗?我已经一字不差地试过了(从xml文件中删除了省略号),但在“客户信息”页面上没有任何内容,没有选项卡,没有错误。@Wrannorn这是在您的模块中进行的,唯一缺少的是模块的声明文件(app/etc/modules/Namespace/module.xml
),但我假设您已经有了。这不应该逐字使用,这不是它的工作方式:例如,我非常确定您的名称空间不是名称空间,您的模块也不是模块。这是您需要的代码,但是您必须理解它并修改它以匹配specs.mmm,这似乎是解决问题的一种非常有趣的方法:php-xml-和phtml文件作为标记。。所有这些都很好,但我认为更好的做法是回显未编码的输出,或者在身体前面的头部将字符设置为“utf-8”,如上图所示。我相信这对于可读性是如此,因为渐进增强的观点。。。是这样的:~
class Russellalbin_Customertab_Adminhtml_CustomertabController extends Mage_Adminhtml_Controller_Action
{
function resetAction()
{
$params = array();
$path = 'customer';
$customer_id = (int)$this->getRequest()->getParam('customer_id');
if($customer_id)
{
// Do your stuff here
$params['id'] = $customer_id;
$params['back'] = 'edit';
$params['tab'] = 'customer_edit_tab_action';
$path = 'adminhtml/customer/edit/';
}
$params['_store'] = Mage::getModel('core/store')->load(0);
$url = Mage::getModel('adminhtml/url')->getUrl($path, $params);
Mage::app()
->getResponse()
->setRedirect($url);
Mage::app()
->getResponse()
->sendResponse();
exit;
}
}
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_customer_edit>
<reference name="customer_edit_tabs">
<action method="addTab">
<name>customer_edit_tab_action</name>
<block>customertab/adminhtml_customer_edit_tab_action</block>
</action>
</reference>
</adminhtml_customer_edit>
</layout>
<div id="customer_info_tabs_customer_edit_tab_action_content">
<div class="entry-edit">
<div class="entry-edit-head">
<h4 class="icon-head head-edit-form fieldset-legend">Pull List</h4>
</div>
<div id="group_fields4" class="fieldset fieldset-wide">
<div class="hor-scroll">
<h2>This is my form and content that I can submit and return back to this page and tab</h2>
<div><form action="<?php echo $this->getUrl('adminhtml/customertab/reset/', array('customer_id'=> $customer_id)); ?>" method="get"><input type="submit" value="Post This Form" /></form></div>
</div>
</div>
</div>
</div>