如何从CMS安装位置上方的一个位置访问CMS的记录


How to access records of a CMS from one location above where it is installed?

我使用CMS Bolt,它使用Twig模板引擎。我需要访问上面运行CMS的页面中创建的内容。

示例:螺栓安装在博客文件夹中;访问和显示内容的页面是测试站点test/blog

我在页面上使用这个:

{% setcontent records = "entries/latest/2" allowpaging %}
{% for record in records %}
   <div class="four columns thumb" style="margin-left: 0px; clear: both";>
      {% if record.image!="" %}
      <img src="{{ thumbnail(record.image, 100, 100) }}" alt="thumbnail" class="u-max-full-width">
      {% endif %}
   </div>
   <div class="eight columns">
      <small class="date">{{ record.datecreated|date("d.m.y") }}</small>
      <p><a href="{{ record.link }}" class="footer_last_blog">{{ record.excerpt(75) }}</a></p>
   </div>
{% endfor %}

我不确定你想链接到什么,链接、主题资产等的处理方式都略有不同,但你总是可以从路径向上导航,因为路径总是打印为字符串。。。

所以除了{{paths.theme}}/images,你还可以做{{paths.theme}}/../images并返回一个级别。

同样,您可以通过{{paths.root}}/../ 从根目录向上移动一个目录