简体   繁体   English

如果在magento中满足特定条件,如何加载其他.phtml文件?

[英]How to load a different .phtml file if a specific condition is met in magento?

I am currently using a .phtml file for a specific page which works well in all modern browsers in magento. 我目前正在为特定页面使用.phtml文件,该文件在magento的所有现代浏览器中均能正常工作。 But it is not properly rendered in IE6, IE7. 但是在IE6,IE7中无法正确呈现。 Is there a way in magento by which I can load a different .phtml file from the .xml file if it is an old browser, instead of writing an if condition inside my .phtml page ? 在magento中,是否有一种方法可以通过旧的浏览器从.xml文件加载不同的.phtml文件,而不是在.phtml页面中编写if条件? Also, Is there any other method through which a different .phtml can be loaded ? 另外,是否有其他方法可以加载不同的.phtml文件?

Browser detection is done client side AFTER the page has been delivered, which means that the server doesn't know what browser the user will have until after the .phtml files have been run and delivered. 页面交付后,客户端将在客户端进行浏览器检测,这意味着直到.phtml文件运行并交付后,服务器才知道用户将拥有哪种浏览器。 You can do this as an ajax call, but it would be a little weird to do that in Magento for a full page. 您可以将其作为ajax调用来进行,但是在Magento中将其整页显示会有些奇怪。

Honestly... its 2015, the percentage of people using IE6/7 is so low, and those people probably aren't making purchases anyway, you would probably just be safe delivering a message at the top of the screen that says "update your browser for a full experience" and this can be done in either CSS or JS with simple browser detection. 坦白说...在2015年,使用IE6 / 7的用户比例非常低,而且这些人可能仍未进行购买,您可能会很安全地在屏幕顶部传递一条消息,说“更新您的浏览器以获得完整的体验”,并且可以通过CSS或JS通过简单的浏览器检测来完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM