【问题标题】:Update a field of a content entry in Locomotivecms更新 Locomotivecms 中内容条目的字段
【发布时间】:2015-03-27 10:18:46
【问题描述】:

在 Locomotivecms 中,我创建了一个名为“posts”的内容类型,其中包含一个名为“views”的整数字段。每次访问内容条目页面时,“views”字段应该递增 1。 我在液体中尝试 {% assign post.views = post.views +1 %} ,但这没有意义。 有没有液体标签可以执行?

【问题讨论】:

    标签: ruby-on-rails locomotivecms


    【解决方案1】:

    你可能想试试{% increment post.views %}

    【讨论】:

      【解决方案2】:

      您可以通过这种方式在机车 CMS 中递增:

      {% assign counter = 0 %}
      {% capture counter %}{{ counter | plus: 1 }}{% endcapture %}
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-11-07
        • 1970-01-01
        • 2018-02-01
        • 2017-07-14
        • 1970-01-01
        • 2020-01-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多