简体   繁体   English

我可以在magento新主题中添加第二个media.phtml吗?

[英]can i have a second media.phtml in my magento new theme?

so this is the project. 所以这是项目。

I need to display the regular product images for most of the products but for a second set of products i need to replace the image with a javascript that will change depending on selections of options. 我需要显示大多数产品的常规产品图片,但对于第二组产品,我需要使用JavaScript替换图片,该JavaScript会根据选项的选择而变化。

My question is: can i have two different media.phtml. 我的问题是:我可以有两个不同的media.phtml吗? Let's say media.phtml and js-media.phtml. 假设media.phtml和js-media.phtml。 And if i can where can i change this? 如果我能在哪里改变呢?

Or another case could be finding the file responsible for the content on the product page and change it there. 或者另一种情况是在产品页面上找到负责内容的文件并在此处进行更改。

 <?php echo $this->getChildHtml('content') ?>

I thought i could change this creating a new layout file but apparently i am wrong. 我以为我可以更改此设置以创建新的布局文件,但是显然我错了。

Thanks 谢谢

This is totally something you can do. 这完全是您可以做的。

In your template create your js-media.phtml in templates/catalog/product/view . 在您的模板中,在templates/catalog/product/view创建js-media.phtml

Then if you want to assign this new template only to some of the products, you can switch media template straight from the backend of magento, through the Design tab of a product info. 然后,如果您只想将此新模板分配给某些产品,则可以通过产品信息的“ Design选项卡直接从magento后端切换媒体模板。

There you can do this by adding a bit of XML into the Custom Layout Update field : 在那里,您可以通过在“ Custom Layout Update字段中添加一些XML来做到这一点:

<reference name="product.info.media">
    <action method='setTemplate'><template>catalog/product/view/js-media.phtml</template></action>
</reference>

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

相关问题 getChildHtml(&#39;media&#39;)在view.phtml magento中返回空白 - getChildHtml(‘media’) returning blank in view.phtml magento 我的magento主题主页中的图像模糊了 - Images get blurred in my magento theme homepage Magento-在phtml文件中列出类别,子类别和图像 - Magento - list categories, subcategories, and images in phtml file 我可以使Magento产品视图中的图像具有设定的宽度,但具有可变的高度吗? - Can I make the images in the product view of Magento have a set width, but a fluid height? 如何在magento 1.9.2.4的list.phtml页面上获取缩略图 - how to get thumbnail images on list.phtml page in magento 1.9.2.4 我可以在网站上安装什么快速,批量上传媒体管理系统? - What is a fast, bulk upload, media management system I can install on my website? 我的WordPress主题需要帮助 - I need assistance with my wordpress theme 如何使我的图像在响应时保持其方形形状并且不设置大量媒体查询? - How can I make my image maintain its squared shape when responsive and not set lots of media queries? 如何在媒体查询中隐藏图像? - How can i hide image in media queries? 在list.phtml中更改大小后,Magento类别图像全部模糊 - Magento Category Images are all blurry after changing size within list.phtml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM