magento 产品弹出窗口
我想为产品创建一个弹出窗口,而不是定向到另一个页面。我正在寻找有关基本复制产品视图模板的最佳方法的建议,以便根据我的需要进行修改,而无需创建单独的模型和块。我使用的是1.3.2.2版本。如果有任何事情需要澄清,请告诉我。
我意识到有些模块可以做到这一点,但我想自己做。部分是为了学习。
I'd like to create a popup window for products instead of directing to another page. I'm looking for advice on the best way to basically make a copy of the product view template to modify for my needs without having to create separate models and blocks. I'm using version 1.3.2.2. Let me know if anything needs clarification.
I realize there are modules that do this, but I'd like to do it myself. Partly for learning.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
作为一般方法,您可以使用 Javascript 更改产品页面链接以在弹出窗口中打开(不清楚您是指 AJAX 层还是“真正的”弹出窗口,许多用户的浏览器会阻止它)。然后,修改布局 XML 文件以添加或删除所需的任何块。
如果您想同时拥有普通页面和悬停“层”,则创建一个新控制器并让它继承目录视图布局(IIRC,
$this->loadLayout('catalog_product_view')
应该这样做)。然后,再次更改您的布局标记的布局,以根据需要添加和删除。As a general approach, you could use Javascript to change the product page links to open in a popup (not clear if you mean an AJAX layer or a "real" popup, which many users' browsers will block). Then, modify the layout XML files to add or remove any blocks that you need.
If you want to have both the normal page and a hovered 'layer', then create a new controller and have it inherit from the catalog view layout (IIRC,
$this->loadLayout('catalog_product_view')
should do it). Then, once again, change layouts for your layout tag to add and remove as necessary.约瑟夫的回答对我来说不太清楚,但这就是我所做的。我使用扩展了 ProductController 的新控制器为弹出窗口创建了一个新模块。我制作了 viewAction 的副本,并在新控制器中将其重命名为 popupAction。
然后我复制了catalog.xml并根据我的模块将其重命名。然后删除所有与产品视图页面无关的内容。我复制了视图模板并将其设置为 xml 布局中的模板。然后我在 xml 布局或新视图模板中进行了必要的更改。
我无法让
$this->loadLayout('catalog_product_view')
为我工作。Joseph's answer wasn't quite clear to me, but this is what I did. I created a new module for the popup with a new controller that extended the ProductController. I made a copy of the viewAction and renamed it to popupAction in my new controller.
Then I made a copy of the catalog.xml and renamed it according to my module. Then deleted everyting not pertaining to the product view page. I made a copy of the view template and set that as the template in my xml layout. Then I made the necessary changes within either the xml layout or the new view template.
I couldn't get
$this->loadLayout('catalog_product_view')
to work for me.