gpt4 book ai didi

css - Shopify 造型

转载 作者:行者123 更新时间:2023-12-04 14:33:18 24 4
gpt4 key购买 nike

有什么办法可以在shopify的css中获取页面标识符。

我想在 shopify 特定页面而不是所有页面中进行样式工作。

所以我想指定页面,主页或我构建的页面,博客页面或购物页面等。

最佳答案

你可以使用这样的东西:

替换 <body>主题.液体 与以下之一:

<body class="{{ template }} {{ page.handle }}{% if template == 'collection' %}{{ collection.handle }}{% endif %}{% if template == 'product' %}{{ product.title | handleize }}{% endif %}{% if template == 'blog' %}{{ blog.handle }}{% endif %}{% if template == 'article' %}{{ article.title | handleize  }}{% endif %}">

向页面的 body 元素添加一个类。

为了分解它,这就是我正在做的事情:
{{ template }}
这将返回模板的名称(例如主页的索引、博客页面的博客、商店页面的集合等等)
{{ page.handle }}
返回每个唯一页面的句柄(关于我们、联系我们...只有页面而不是集合、博客、产品)
{% if template == 'collection' %}{{ collection.handle }}{% endif %}{% if template == 'product' %}{{ product.title | handleize }}{% endif %}
我在这里检查页面是否是集合 {% if template == 'collection' %}如果页面是产品 {% if template == 'product' %}并添加集合的句柄 {{ collection.handle }}以及带有 handleize 过滤器的产品页面标题 {{ product.title | handleize }} .我检查页面,因为产品不会以正常方式返回句柄,而我正在使用标题,如果我不检查集合,它也会将其添加到产品页面。
{% if template == 'blog' %}{{ blog.handle }}{% endif %}{% if template == 'article' %}{{ article.title | handleize }}{% endif %}
这一逻辑与集合/产品逻辑相同。

一旦你设置了上面的内容,你就可以为每个页面定位 body 类并以这种方式设置样式。

关于css - Shopify 造型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36512354/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com