简体   繁体   English

Shopify / Liquid - 访问当前标签搜索/过滤器之外的文章

[英]Shopify / Liquid - Access articles outside of current tag search/filter

I have a Shopify blog, in this example called blog1 .我有一个 Shopify 博客,在这个例子中叫做blog1 I would like to use liquid to access all articles within that blog, whilst filtering by a specific tag.我想使用液体访问该博客中的所有文章,同时按特定标签进行过滤。

For instance, supposing I am at the following URL (ie tagging by articles with the tag "chicken").例如,假设我在下面的 URL (即由带有标签“鸡”的文章标记)。

www.website.com/blogs/blog1/tagged/chicken

When I do {% for article in blog.articles %}{{ article.title }}{% endfor %} , it only outputs articles which have the tag "chicken".当我{% for article in blog.articles %}{{ article.title }}{% endfor %}时,它只输出带有“鸡”标签的文章。 I understand that this is normal and expected behaviour for filtering, but I want to know how I can still somehow loop through all articles from this page.我知道这是过滤的正常和预期行为,但我想知道我仍然可以以某种方式循环浏览此页面中的所有文章。

I have looked at Shopify: blog.articles doesn't show all articles when in tagged view but their question is slightly different, and the only answer is not a valid solution in this case: {% for article in blog['blog1'].articles %}{{article.url}}{%endfor%} does not work.我查看了Shopify:blog.articles 在标记视图中不显示所有文章,但他们的问题略有不同,在这种情况下唯一的答案不是有效的解决方案: {% for article in blog['blog1'].articles %}{{article.url}}{%endfor%}不起作用。

You need to refer to the global blogs object and the specific handle of the blog.需要参考全球blogs object和博客的具体句柄。

So the answer you showed is correct but your implementation is not.所以你展示的答案是正确的,但你的实现不是。 The global blogs object is written like so blogs['handle'] and not blog['handle'] .全球博客 object 是这样写blogs['handle']而不是blog['handle']

So in your case it will be like so:所以在你的情况下,它会是这样的:

{% for article in blogs['blog1'].articles %}
  {{article.url}}
{% endfor %} 

Just add the missing s in the blog object.只需在博客 object 中添加缺少s

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

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