1

不能使用事件 content_type_template。重复官方教程(http://doc.locomotivecms.com/guides/content-types/create),并出现错误:找不到页面。请帮忙,我正在尝试解决这个问题 3 小时呢!

/app/content_types/events.yml

name: Events

slug: events

description: List of all events

label_field_name: title

order_by: manually # default: manually, also available: created_at or any field slug

# order_direction: asc # default: asc, also available: desc

# group_by: <your field>

# public_submission_enabled: false

# public_submission_accounts: ['john@acme.net']


fields: 
- title: # Name of the field
    label: Title
    type: string
    required: true

- description: # Name of the field
    label: Description
    type: text
    required: false
    # Enable or not the RTE [html|text]
    # text_formatting: html

- event_date: # Name of the field
    label: Event date
    type: date
    required: false

/app/views/pages/events/content_type_template.liquid *是手动创建的!*

--
title: Event template page

content_type: events

published: true
---
{% extends parent %}

{% block main %}
    <h1>{{ event.title }} on {{ event.event\_date || localized_date: '%m/%d/%Y' }}</h1>
    <p>{{ event.description }}</p>
{% endblock %}

/app/views/pages/index.liquid

{% extends parent %}

{% block main %}

  <ul>
    {% for event in contents.events %}
      <li><a href="/events/{{ event._slug }}">{{ event.title }}</a></li>
    {% endfor %}
  </ul>

{% endblock %}
4

1 回答 1

1

不知道你是否还有这个问题。我遇到了同样的问题,并找出了问题所在:

content_type_template 中有错字。

<h1>{{ event.title }} on {{ event.event\_date || localized_date: '%m/%d/%Y' }}</h1>

应该

<h1>{{ event.title }} on {{ event.event_date || localized_date: '%m/%d/%Y' }}</h1>

数据文件夹中的文件 events.yml 包含带有不可能日期的示例数据。在我的情况下 2013/39/02(格式 y/m/d)

在这两次更正之后,该示例在这里有效。

于 2013-10-03T13:53:24.583 回答