magento管理面板中的颜色选择器

magento管理面板中的颜色选择器,magento,input,colors,admin,picker,Magento,Input,Colors,Admin,Picker,我想在Magento 1.7 CE管理面板中添加一个颜色选择器。 知道我已经使用了自定义选择模型,但我找不到如何添加自定义颜色选择器 有人能帮我吗 谢谢。查看JSColor: 它是一个开源且易于使用的Javascript库。您所要做的就是将库导入应用程序中的某个位置,然后只需使用“color”类创建一个输入。JSColor做其余的。我刚刚在最近的Magento项目中使用了它,希望它也能满足您的需求 更新: 为了更深入地回答海报的问题,以下是我如何在我的magento应用程序中实现jscolor

我想在Magento 1.7 CE管理面板中添加一个颜色选择器。 知道我已经使用了自定义选择模型,但我找不到如何添加自定义颜色选择器

有人能帮我吗

谢谢。

查看JSColor:

它是一个开源且易于使用的Javascript库。您所要做的就是将库导入应用程序中的某个位置,然后只需使用“color”类创建一个输入。JSColor做其余的。我刚刚在最近的Magento项目中使用了它,希望它也能满足您的需求

更新: 为了更深入地回答海报的问题,以下是我如何在我的magento应用程序中实现jscolor的:

首先,确保您已经拉入了JSColor的javascript文件,我在我的模块的layout.xml中这样做了,您也可以这样做:

<layout version="0.1.0">
<default>
    <reference name="head">
        <action method="addJs">
            <script>jscolor/jscolor.js</script>
        </action>
    </reference>
</default>

您还可以将验证颜色添加到字段定义中,它将显示颜色选择器已在管理中自动加载jscolor库

                   <color_field>
                        <label>Color</label>
                        <frontend_type>text</frontend_type>
                        <validate>color</validate>
                        <sort_order>12</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </color_field>

颜色
文本
颜色
12
1.
1.
1.

在MAGENTO管理员配置页面中添加颜色选择器

有时,您可能需要在Magento模块或扩展的管理配置页面中添加颜色选择器。你可能认为这是一项艰巨的任务,但相信我,这是最简单的。只有几行XML代码可以满足您的需要。下面是执行此操作的确切步骤

  • adminhtml/default/default/layout
    目录中,为模块创建布局XML文件。让我们把它命名为
    picker.xml
    。在
    picker.xml
    中编写以下内容:

       <?xml version="1.0"?>
         <layout version="0.1.1">
            <adminhtml_system_config_edit>
               <reference name="head">
                   <action method="addJs"><file>jscolor/jscolor.js</file></action>
               </reference>
            </adminhtml_system_config_edit>
         </layout>
    
  • 在模块的
    system.xml
    中,添加颜色选择器字段,如下所示:

    <config>
       <sections>
         <myconfig module="picker" translate="label">
      <groups>
    <my_group translate="label">
      <my_color>
       <label>Background Color</label>
       <frontend_type>text</frontend_type>
       <validate>color</validate> <!-- This is important -->
       <sort_order>1</sort_order>
       <show_in_default>1</show_in_default>
       <show_in_website>1</show_in_website>
       <show_in_store>1</show_in_store>
       <comment>Specify the background color.</comment>
      </my_color>
    <my_group>
    
    
    背景色
    文本
    颜色
    1.
    1.
    1.
    1.
    指定背景色。
    

  • 就这样,你完了它将在管理系统配置字段中显示如下:-


    谢谢你,Emil,但我的问题是如何将jscolor添加到magento的管理面板没有问题,很高兴我能提供帮助:)我尝试了你建议的方法,但没有激活颜色选择器
       <?xml version="1.0"?>
         <layout version="0.1.1">
            <adminhtml_system_config_edit>
               <reference name="head">
                   <action method="addJs"><file>jscolor/jscolor.js</file></action>
               </reference>
            </adminhtml_system_config_edit>
         </layout>
    
    <config>
     ...
       <adminhtml>
         <layout>
           <updates>
             <basket>
               <file>picker.xml</file>
             </basket>
           </updates>
         </layout>
       </adminhtml>
     ...
    </config>
    
    <config>
       <sections>
         <myconfig module="picker" translate="label">
      <groups>
    <my_group translate="label">
      <my_color>
       <label>Background Color</label>
       <frontend_type>text</frontend_type>
       <validate>color</validate> <!-- This is important -->
       <sort_order>1</sort_order>
       <show_in_default>1</show_in_default>
       <show_in_website>1</show_in_website>
       <show_in_store>1</show_in_store>
       <comment>Specify the background color.</comment>
      </my_color>
    <my_group>