shopify - 标记过滤器到 Shopify
问题描述
我想根据前缀过滤标签。假设我的标签为 filter-material-woolen、filter-material-woolen1、filter-febric-velvet、filter-febric-velvet1。所以我必须过滤带有前缀“filter-”的标签,中间关键字如“material,febric”将作为标题,最终键将作为值。
<h1>material</h1>
<p>woolen1,woolen</p>
<h1>febric</h1>
<p>velvet,velvet1</p>
解决方案
<ul>
{% for tag in collection.all_tags %}
{% if tag contains 'filter-' %}
<li>{{ tag | remove: 'filter-material-' | remove: 'filter-febric-' | link_to_tag: tag }}</li>
{% endif %}
{% endfor %}
</ul>
推荐阅读
- python - 无论我如何指定它,我的 Selenium Webdriver 都找不到按钮
- arrays - 如何在arduino中存储和调用多个字母?
- php - PHP curl_multi_exec apache限制?
- node.js - Express 应用程序在 Azure 上成功部署,但仍然没有任何效果
- php - 如何为 JQuery 和 Codeigniter 4 启用或允许 Access-Control-Allow-Origin
- php - Plesk Laravel 调度程序不运行
- javascript - 服务器返回http 500错误时如何使用chrome扩展名自动重新加载页面
- php - 在 codeigniter 中从 Legacy stripe checkout 迁移到新版本
- xml - 使用 PowerShell 解析 XML 文件
- go - Go中未定义的函数位于本地包中