我为站点上的每个策略创建了一个单独的模板,如何在每个模板上只显示特定的策略,下面是我为此编写的代码:
<div class="flex flex-col items-center my-8">
{% for policy in shop.policies %}
<h1 class="text-5xl font-bold tracking-tighter my-4 md:my-8">{{ policy.title }}</h1>
<div class="py-2 mb-4 inline-flex items-center justify-center text-xs font-semibold tracking-tighter">
<span class="mr-2">
{{ 'general.last_updated' | t }}
</span>
{{ policy.published_at | date: '%d/%B/%Y' }}
</div>
<div class="max-w-5xl mx-auto px-4">{{ policy.body }}</div>
{% endfor %}
</div>我尝试使用句柄筛选器访问策略对象,例如:
{{ policy['terms-of-service'].title }}但是它不起作用,任何人都能指导我,我怎么能让它起作用?(预先谢谢:)
编辑:
下面是我目前使用shop.privacy_policy的代码,但是可以在部分中创建一个循环,创建2个策略。
<div class="flex flex-col items-center my-8">
{% for policy in shop.policies %}
<h1 class="text-5xl font-bold tracking-tighter my-4 md:my-8">{{ shop.privacy_policy.title }}</h1>
<div class="py-2 mb-4 inline-flex items-center justify-center text-xs font-semibold tracking-tighter">
<span class="mr-2">
{{ 'general.last_updated' | t }}
</span>
</div>
<div class="max-w-5xl mx-auto px-4">{{ shop.privacy_policy.body }}</div>
{% endfor %}
</div>还有一些图像来表达我的意思:

发布于 2022-09-24 14:55:35
实际上,每一家店内的保单都有一条便条。
shop.privacy_policy shop.refund_policy shop.shipping_policy shop.subscription_policy shop.terms_of_service
https://stackoverflow.com/questions/73838024
复制相似问题