我有一个自定义模块,可以在一个元素中添加一个字段
<?php
class NS_MN_Block_Cms_Page_Edit_Tab_Main extends Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Main
{
public function _prepareForm()
{
parent::_prepareForm();
$fieldset = $this->getForm()->getElements()->searchById('base_fieldset');
$fieldset->addField('bar', 'text',
array(
'label' => Mage::helper('cms')->__('BaR'),
'class' => 'input-text',
'name' => 'bar',
'required' => false
)
);
return $this;
}
}
Run Code Online (Sandbox Code Playgroud)
我已将bar字段添加到cms_page表中并且字段已呈现,但是当我保存cms页面时,该字段不会保存到数据库中.
谁能告诉我我在这里俯瞰什么?
我正在使用Magento社区版1.7版.
我在管理面板中有一个网格.现在,当我点击此URL时,它会在左侧边栏中打开一个带有两个标签的表单.当我点击第二个标签时,它会在右侧显示一个网格.
然后我点击此网格的一行,在另一页上打开一个表单.在这种形式有后退按钮.
如何将其URL更改为上一页?
我正在努力创造我希望有一天会成为Magento公开扩展的部分(这部分我提到因为我在这里做"正确的事"对我来说很重要).我想做的其中一件事是在默认的Magento仪表板中添加一个框,基本上是一个新的"框",与"前5个搜索术语"完全相同,除了我自己的内容.我希望我的新自定义框是显示的最后一个框(理想情况下).
我遇到的问题是,负责呈现仪表板的模板会调出要呈现的特定块,并且这些块嵌套在html中.换句话说,通常存在一个区域,其中子块将被渲染成一个合理的HTML元素,在这种情况下,似乎会呈现特定的块.以下是/app/design/adminhtml/default/default/template/dashboard/index.phtml的内容
<div class="dashboard-container">
<?php echo $this->getChildHtml('store_switcher') ?>
<table cellspacing="25" width="100%">
<tr>
<td><?php echo $this->getChildHtml('sales') ?>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Last 5 Orders') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('lastOrders'); ?></fieldset>
</div>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Last 5 Search Terms') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('lastSearches'); ?></fieldset>
</div>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Top 5 Search Terms') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('topSearches'); ?></fieldset>
</div>
</td>
<td>
<div class="entry-edit" style="border:1px solid #ccc;">
<?php echo $this->getChildHtml('diagrams') ?>
<?php if (is_array($this->getChild('diagrams')->getTabsIds())) : …Run Code Online (Sandbox Code Playgroud) 我想从core/Mage/Adminhtml/controllers/Catalog/ProductController.php重载saveAction方法,它不起作用 - 我现在已经搜索并尝试了一整天:(
背景:我想在保存产品之前更改自定义属性的值.我发现,_initProductSave设置属性,我认为,在init_ProductSave之后更改它们将是一个好点(如果有人知道更好的地方,请告诉我)...
愿任何人请帮助我... :)
Magento版本: Community Edition版本1.7.0.1没有扩展,没有安装主题,我刚安装这个版本完全空白...
版本1:通过复制到本地/ Mage文件夹覆盖控制器
首先,我尝试将文件复制到app/code/local文件夹中,在正确的结构中 - 但它不起作用(我已经使用Varient.php进行本地测试系统和stores.php来纠正价格错误 - 因为它的工作......)
版本2:用扩展名覆盖控制器
我的扩展程序如下所示:
文件结构:
code/local/MyOne/MyExtension/controllers/Catalog/ProductController.php
code/local/MyOne/MyExtension/etc/config.xml
etc/modules/MyOne_MyExtension.xml
Run Code Online (Sandbox Code Playgroud)
这些文件如下所示:MyOne_MyExtension.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<MyOne_MyExtension>
<active>true</active>
<codePool>local</codePool>
</MyOne_MyExtension>
</modules>
</config>
Run Code Online (Sandbox Code Playgroud)
代码/本地/ MyOne/MyExtension的/ etc/config.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<MyOne_MyExtension>
<version>1.0.0</version>
</MyOne_MyExtension>
</modules>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<MyOne_MyExtension before="Mage_Adminhtml">MyOne_MyExtension_Catalog_ProductController</MyOne_MyExtension>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Run Code Online (Sandbox Code Playgroud)
最后一个,代码/ local/MyOne/MyExtension/controllers/Catalog/ProductController.php:
<?php
require_once 'Mage/Adminhtml/controllers/Catalog/ProductController.php';
class MyOne_MyExtension_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
{
public function saveAction()
{
// do my stuff
die('reached …Run Code Online (Sandbox Code Playgroud) 我正在制作一个新的Magento扩展,在我的Adminhtml表单中我想添加按钮"saveAndContinueEdit"
我已将此代码添加到Edit.php文件中.
$this->_addButton('saveandcontinue', array(
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
'onclick' => 'saveAndContinueEdit()',
'class' => 'save',
), -100);
Run Code Online (Sandbox Code Playgroud)
但是,当我点击它时,我有这个JavaScript错误:
Erreur:ReferenceError:saveAndContinueEdit未定义Fichier来源: http://XXXX/magento/index.php/slider/adminhtml_config/new/key
你能帮助我吗 ?
谢谢
我正在尝试在管理页面中获取布局.
如果我在我的控制器(Highor_Plugin_StatisticsController)中执行var_dump,那么我会看到转储.
这是我到目前为止:
应用程序/代码/本地/ Highor /插件的/ etc/config.xml中
<?xml version="1.0"?>
<config>
<modules>
<highor_plugin>
<version>1.0.0</version>
<depends>
<!-- no dependencies -->
</depends>
</highor_plugin>
</modules>
<global>
<models />
<blocks />
<resources />
<extraconfig />
<helpers>
<highorplugin>
<class>Highor_Plugin_Helper</class>
</highorplugin>
</helpers>
</global>
<admin>
<routers>
<highorplugin>
<use>admin</use>
<args>
<module>Highor_Plugin</module>
<frontName>highorplugin</frontName>
</args>
</highorplugin>
</routers>
</admin>
<adminhtml>
<layout>
<updates>
<highor_plugin>
<file>highorplugin.xml</file>
</highor_plugin>
</updates>
</layout>
</adminhtml>
</config>
Run Code Online (Sandbox Code Playgroud)
应用程序/设计/ adminhtml /默认/缺省/布局/ highorplugin.xml
<?xml version="1.0"?>
<layout>
<highorplugin_statistics_index>
<reference name="content">
<block type="core/template" name="highor" template="highor/plugin.phtml" />
</reference>
</highorplugin_statistics_index>
</layout>
Run Code Online (Sandbox Code Playgroud)
应用程序/设计/前端/基/默认/模板/ highor/plugin.phtml
一些文字......
我对Magento很新,我正在尝试为Magento后端的客户视图添加一个新选项卡.
我为它制作了一个新的扩展/模块.以下是我的etc/config.xml的一些摘录:
<global>
<blocks>
<showidea>
<class>Whatever_Extendcustomer_Block</class>
</showidea>
</blocks>
<!-- ... -->
</global>
<adminhtml>
<layout>
<updates>
<showidea>
<file>whatever_extendcustomer.xml</file>
</showidea>
</updates>
</layout>
</adminhtml>
Run Code Online (Sandbox Code Playgroud)
这里是whatever_extendcustomer.xml文件的内容:
<adminhtml_customer_edit>
<reference name="customer_edit_tabs">
<action method="addTab">
<name>extendcustomer_showidea</name>
<block>extendcustomer/adminhtml_customer_showidea</block>
</action>
</reference>
</adminhtml_customer_edit>
Run Code Online (Sandbox Code Playgroud)
当然这个块是存在的,它扩展了Mage_Adminhtml_Block_Template并实现了Mage_Adminhtml_Block_Widget_Tab_Interface.
当我转到客户的详细信息时,我现在得到错误:错误的选项卡配置.在Magento的错误日志中:
异常'Mage_Core_Exception',消息'无效的Blocktype:Mage_Extendcustomer_Block_Adminhtml_Customer_Showidea'在/var/www/vhosts/whatever/htdocs/app/Mage.php:594
我认为这是问题,因为Mage_Extendcustomer是错的.它应该是Whatever _ ...但我不知道为什么它在Mage_而不是我的Whatever_命名空间之前.
我希望有人能给我一些线索!谢谢.
我在magento中制作了一个自定义网格,显示已保存的视频网址及其工作情况.但我想只显示记录中,其中urlid是例如3.这是我的_prepareCollection功能
protected function _prepareCollection()
{
// Get and set the collection for the grid
$collection = Mage::getResourceModel('drecomm_productvideo/video_collection');
//what should i put in here, addFieldtoSelect?
$this->setCollection($collection);
return parent::_prepareCollection();
}
Run Code Online (Sandbox Code Playgroud)
我的网格延伸,Mage_Adminhtml_Block_Widget_Grid并且addFieldToFilter该类中没有任何功能.
首先让我说我已禁用并清除缓存并注销并重新登录.但是,我仍然收到此错误.
其次,让我解释一下我要做的事情.顺便说一下,这是我的第一个扩展构建:)我只是想构建一个扩展,如果它被启用它将覆盖原始的cart/shipping.phtml文件与我自己的模板文件..
我可以在管理员配置下的左侧边栏中看到我的扩展程序.但是,当我点击我的扩展程序以提取允许您禁用或启用它的常规选项卡时,我找不到可怕的404页面.你能看看我的代码,让我知道我做错了什么吗?感谢所有帮助的人!
这是我的所有文件:)
等/ config.xml中
<?xml version="1.0"?>
<config>
<modules>
<Beckin_DropDownShipping><version>1.0.0</version></Beckin_DropDownShipping>
</modules>
<global>
<blocks>
<dropdownshipping>
<class>Beckin_DropDownShipping_Block</class>
</dropdownshipping>
</blocks>
<helpers>
<dropdownshipping>
<class>Beckin_DropDownShipping_Helper</class>
</dropdownshipping>
</helpers>
</global>
<frontend>
<layout>
<updates>
<beckin>
<file><!-- beckin_dropdownshipping.xml --></file>
</beckin>
</updates>
</layout>
<routers>
<dropdownshipping>
<use>standard</use>
<args>
<module>Beckin_DropDownShipping</module>
<frontName>dropdownshipping</frontName>
</args>
</dropdownshipping>
</routers>
</frontend>
<adminhtml>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<dropdownshipping_options>
<title>Beckin Drop Down Shipping Extension</title>
</dropdownshipping_options>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>
Run Code Online (Sandbox Code Playgroud)
等/的system.xml
<?xml version="1.0"?>
<config>
<tabs>
<beckin translate="label">
<label>Beckin Extensions</label>
<sort_order>100</sort_order> …Run Code Online (Sandbox Code Playgroud) 我想用自定义实体编写一个模块.在后端,它看起来像产品的后端(左侧的标签,右侧的表格).
我尝试了很多变种,并从核心检查/复制了许多东西以便理解它......我不这样做.
谁知道任何教程或必要的关键点来实现这一点?
非常感谢
编辑:嗯,这不是创建自己的实体的问题,这是众所周知的.我需要帮助来创建后端,以便在编辑产品时结果看起来像标签形式
我目前正试图简单地将一个块添加到自定义Adminhtml模块.我能够显示块的内容,但它在页面顶部呈现灰色背景,然后标准的magento布局与设计和菜单直接呈现在它下面.
我试图以正确的方式做事情,以学习最佳实践,并遵循书籍和教程以及magento核心,但到目前为止一直无法正确添加内容.
到目前为止我有:
public function indexAction()
{
$this->loadLayout();
$this->_setTitle();
$main_block = new Invent_General_Block_Info();
echo $main_block->toHtml();
//$this->_addContent($main_block);
$this->renderLayout();
Run Code Online (Sandbox Code Playgroud)
我可以看到在Mage Core中这样做的一般方法就像是
/**
* Append customers block to content
*/
$this->_addContent(
$this->getLayout()->createBlock('adminhtml/customer', 'customer')
);
Run Code Online (Sandbox Code Playgroud)
因为我已经创建了块$ main_block,所以对我来说没有意义 - > createBlock,所以我不知道该怎么做.
任何协助都像往常一样受到赞赏 谢谢!
我正在为magento开发一个定制模块,用于列出员工.
我几乎找到了一切.我唯一剩下的就是如何突出显示所选的值.
我遇到的问题是后端问题.
我为每位员工提供了2个选项卡,一个用于员工数据,另一个用于magento类别.
1名员工可以拥有1个或更多类别.
存储类别的数据库表是非eav表.
所以我的问题是多选中的内容决定选择哪些值?就像现在一样,只选择一个值.