【问题标题】:Change code to expand blog entry on Shopify Couture theme (Django?)更改代码以扩展 Shopify Couture 主题(Django?)的博客条目
【发布时间】:2011-11-05 16:31:20
【问题描述】:

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

谢谢,

大卫

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' %}

【问题讨论】:

  • 我不知道这是什么,但绝对不是 PHP。
  • 谢谢我刚刚更新了标签以避免任何混淆......

标签: blogs liquid shopify


【解决方案1】:

啊哈!它是用 Liquid (http://liquidmarkup.org/) 编写的。 truncatewords method 获取文章内容并将其缩短到最多 70 个字。删除该方法调用应该可以解决问题。还有一个 strip_html method 似乎会从文章内容中删除任何 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' %}

【讨论】:

  • 抱歉,我的技能只是基本的 css / html。这取自一个名为 Couture 的 shopify 主题。如果有帮助,该文件有一个 .liquid 扩展名?
  • 我刚刚意识到我的博客帖子看起来不错,下一个任务将是限制博客上每页的帖子数量以及以前的条目链接。我认为这可能有点复杂?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多