简体   繁体   English

如何在Drupal 8的主题模板中覆盖商务产品详细信息tpl.twig(commerce-product.html.twig)?

[英]How to overwrite commerce product details tpl.twig (commerce-product.html.twig) in theme template in drupal 8?

I created a bunch of products, but I need to style them per the designer's design. 我创建了很多产品,但是我需要根据设计师的设计来设计样式。 I know that I have to overwrite the template from /modules/contrib/commerce/modules/product/templates/commerce-product.html.twig but where do I put it in my theme? 我知道我必须从/modules/contrib/commerce/modules/product/templates/commerce-product.html.twig覆盖模板,但是在主题中该放在哪里?

Does it go to the root of my templates folder? 它会转到我的模板文件夹的根目录吗? What is the correct way to style the single product page? 设置单个产品页面样式的正确方法是什么?

From the docs https://www.drupal.org/docs/8/theming/twig/working-with-twig-templates : 从文档https://www.drupal.org/docs/8/theming/twig/working-with-twig-templates中

  1. Locate the template you wish to override. 找到您要覆盖的模板。
  2. Copy the template file from its base location into your theme folder. 将模板文件从其基本位置复制到主题文件夹中。
  3. (optionally) Rename the template according to the naming conventions in order to target a more specific subset of areas where the template is used. (可选)根据命名约定重命名模板,以便针对使用模板的区域的更特定子集。
  4. Modify the template to your liking. 根据您的喜好修改模板。

You may have to clear the caches to have Drupal recognize the new file. 您可能需要清除缓存以使Drupal识别新文件。

So usually you have a templates folder in your theme, there you can drop all custom twig files. 因此,通常您的主题中有一个templates文件夹,您可以在其中放置所有自定义的树枝文件。

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

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