如何在 Magento Admin 中填充图片库表单
我可以看到 Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content::getImagesJson()
和 app\design\adminhtml\default\default\template\catalog\product\helper\gallery.phtml
负责放置通过 Product.Gallery
原型类将图像数据传输到浏览器中。
但是,我无法追踪在 Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content
块上设置图像集合的位置。我假设它是通过控制器或布局中某处的魔术设置器实现的,但我无法追踪它。
Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content::getImagesJson()
有
$value = $this->getElement()->getValue();
if(count($value['images'])>0) {
foreach ($value['images'] as &$image) {
一些东西正在填充该块的 element
属性。
Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content
似乎是由 Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery::getContentHtml()
实例化的,但不会在块上设置任何属性。
我可以看到 Mage_Catalog_Model_Product_Attribute_Backend_Media::afterLoad()
使用与 Product.Gallery
Javascript 正在查找的结构相匹配的数组填充属性,但我仍然是对于属性与渲染块的绑定位置有点困惑。
我想我需要一个图表来让这个错综复杂的网络在我的脑海中保持清晰!
谢谢,
乔纳森
I can see that Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content::getImagesJson()
and app\design\adminhtml\default\default\template\catalog\product\helper\gallery.phtml
are responsible for putting the image data into the browser via the Product.Gallery
prototype class.
However, I can't track down where the image collection gets set on the Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content
block. I'm assuming its via a magic setter somewhere in the controller or layout, but I can't track it down.
Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content::getImagesJson()
has
$value = $this->getElement()->getValue();
if(count($value['images'])>0) {
foreach ($value['images'] as &$image) {
so something is populating the element
attribute of that block.
Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content
seems to be instantiated by Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery::getContentHtml()
but that doesn't set any attributes on the block.
I can see that Mage_Catalog_Model_Product_Attribute_Backend_Media::afterLoad()
populates the attribute with an array that matches the structure that the Product.Gallery
Javascript is looking for, but I'm still a little mystified as to where the Attribute gets tied to the rendering Block.
I think I need a diagram to keep this tangled web straight in my head!
Thanks,
Jonathan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你说;
但是
getContentHtml()
看起来像这样:它明确地将
$content
的element
设置为$this
,即Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery
对象。You say;
But
getContentHtml()
looks like this:It clearly sets the
element
for$content
to$this
, which is theMage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery
object.答案就在我眼前。
eav_attribute
中的media_gallery
属性将Mage_Catalog_Model_Product_Attribute_Backend_Media
定义为执行afterLoad
magic-setter 的后端类。仍然不确定
Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery
附加到产品编辑屏幕选项卡的位置,有人知道吗?The answer was right in front of me. The
media_gallery
attribute ineav_attribute
definesMage_Catalog_Model_Product_Attribute_Backend_Media
as its backend class which does theafterLoad
magic-setter.Still not exactly sure where the
Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery
gets attached to the product edit screen Tabs, anyone know?我发现这是在
Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
中完成的。查看第 74 行:
如果您注释掉此代码,“图像”选项卡将消失。
这个画廊里有很多“魔法”,我在这里打开了另一个关于它的讨论:
https://stackoverflow.com/questions/ 11740995/how-to-include-magento-image-gallery-in-a-custom-module-backend
我希望它有帮助:)
I found out that this is done in
Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
Look at line 74:
If you commented it out this code the "Images" tab will disappear.
There is a lot of "magic" in this gallery, I have open another discussion about it here:
https://stackoverflow.com/questions/11740995/how-to-include-magento-image-gallery-in-a-custom-module-backend
I hope it helps :)