更改代码以扩展 Shopify Couture 主题(Django?)上的博客条目

发布于 2024-12-13 14:42:39 字数 954 浏览 4 评论 0原文

您好,有谁知道如何更新下面的代码,以便博客“摘录”完全扩展为全文和图像/视频,而无需点击?

谢谢,

大卫

div id="blog" class="clearfix">
{% paginate blog.articles by settings.pagination_limit %}
<div class="more-info clearfix">
<span class="upper">{{ blog.title }}</span>
<span class="lower">{{ blog.articles_count }} {{ blog.articles_count | pluralize:      'Article', 'Articles' }}</span>
</div>

{% for article in blog.articles %}
<div class="article clearfix">
<div class="content">
  <h4><a href="{{ article.url }}">{{ article.title }}</a></h4>
  {{ article.content | strip_html | truncatewords:70 }}
</div>
</div> <!-- /.article -->
{% endfor %}
</div> <!-- /.main -->
{% include 'sidebar' %}
</div> <!-- /.articles -->

{% include 'pagination' %}
{% endpaginate %}
</div> <!-- /#blog -->
{% include 'featured-products' %}

Hi does anyone know how to update the code below so that blog 'excerpts' are fully expanded with full text and image/video removing the need to click through?

Thanks,

David

div id="blog" class="clearfix">
{% paginate blog.articles by settings.pagination_limit %}
<div class="more-info clearfix">
<span class="upper">{{ blog.title }}</span>
<span class="lower">{{ blog.articles_count }} {{ blog.articles_count | pluralize:      'Article', 'Articles' }}</span>
</div>

{% for article in blog.articles %}
<div class="article clearfix">
<div class="content">
  <h4><a href="{{ article.url }}">{{ article.title }}</a></h4>
  {{ article.content | strip_html | truncatewords:70 }}
</div>
</div> <!-- /.article -->
{% endfor %}
</div> <!-- /.main -->
{% include 'sidebar' %}
</div> <!-- /.articles -->

{% include 'pagination' %}
{% endpaginate %}
</div> <!-- /#blog -->
{% include 'featured-products' %}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

有木有妳兜一样 2024-12-20 14:42:39

啊哈!它是用 Liquid (http://liquidmarkup.org/) 编写的。 truncatewords 方法采用文章的内容并将其缩短至最多 70 个字。删除该方法调用应该可以解决问题。还有一个 strip_html 方法似乎从文章内容中删除了任何 HTML。如果博客文章中有任何显示图像或视频的 HTML,则此方法可能是删除它们的罪魁祸首。这可能会解决您的问题:

<div id="blog" class="clearfix">
{% paginate blog.articles by settings.pagination_limit %}
<div class="more-info clearfix">
<span class="upper">{{ blog.title }}</span>
<span class="lower">{{ blog.articles_count }} {{ blog.articles_count | pluralize:      'Article', 'Articles' }}</span>
</div>

{% for article in blog.articles %}
<div class="article clearfix">
<div class="content">
  <h4><a href="{{ article.url }}">{{ article.title }}</a></h4>
  {{ article.content }}
</div>
</div> <!-- /.article -->
{% endfor %}
</div> <!-- /.main -->
{% include 'sidebar' %}
</div> <!-- /.articles -->

{% include 'pagination' %}
{% endpaginate %}
</div> <!-- /#blog -->
{% include 'featured-products' %}

Aha! It’s written with Liquid (http://liquidmarkup.org/). The truncatewords method takes the article’s content and shortens it to a maximum of 70 words. Removing that method call should fix the problem. There’s also a strip_html method that seems to remove any HTML from an article’s content. If there’s any HTML in the blog post that displays images or videos, this method may be to blame for removing them. This may fix your problem:

<div id="blog" class="clearfix">
{% paginate blog.articles by settings.pagination_limit %}
<div class="more-info clearfix">
<span class="upper">{{ blog.title }}</span>
<span class="lower">{{ blog.articles_count }} {{ blog.articles_count | pluralize:      'Article', 'Articles' }}</span>
</div>

{% for article in blog.articles %}
<div class="article clearfix">
<div class="content">
  <h4><a href="{{ article.url }}">{{ article.title }}</a></h4>
  {{ article.content }}
</div>
</div> <!-- /.article -->
{% endfor %}
</div> <!-- /.main -->
{% include 'sidebar' %}
</div> <!-- /.articles -->

{% include 'pagination' %}
{% endpaginate %}
</div> <!-- /#blog -->
{% include 'featured-products' %}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文