Drupal - 用于 RSS 时的日期字段语言
Drupal - date field language when used for RSS
我对以下场景有疑问。
我设置了一个 date field 类型为 "Date (ISO format)" 的节点。
为了在 RSS 提要中显示该节点,我从内容和格式 RSS 提要创建了一个视图。此外,我在 Drupal 中通过 "r" (RFC 2822) 或 (D, d M Y H:i:s O) 设置了自定义日期格式,并将其用于该字段 "field_time"。该字段用作 pubDate。
日期字段创建而不是:
Wed, 01 Jul 2015 00:00:00 +0200
"german" 版本。
Mi, 01 Jul 2015 00:00:00 +0200
如果我对 "created" 日期做同样的事情,我会得到正确的英文输出。
我已经尝试将那个视图的 "field language" 设置为英文。
我还尝试以编程方式更改 tpl 行中的输出(淹没了我的 php 知识)。
它与 here 非常相似。
也许有人可以给我提示来更改该字段,在行模板或类似的东西中更改它。
提前致谢!
经过一些尝试和错误后,我通过字段级别的视图模板重写了字段 "field_time" 的输出。我从字段中获取原始值,将其转换为 RFC 2822 格式 "again",并以英语显示。
$rawdate = $row->field_data_field_time_field_time_value;
$unixdate = strtotime($rawdate);
print date('r', $unixdate);
之后我对其进行了一些修改,以使提要中的其他节点也只有例如node_created 通过 "rewrite if empty" 在视图 UI.
if (isset($row->field_data_field_time_field_time_value)) {
$rawdate = $row->field_data_field_time_field_time_value;
$unixdate = strtotime($rawdate);
print date('r', $unixdate);
} else {
print $output;
}
我不确定,如果那很干净。仍然欢迎提出建议。
我对以下场景有疑问。 我设置了一个 date field 类型为 "Date (ISO format)" 的节点。 为了在 RSS 提要中显示该节点,我从内容和格式 RSS 提要创建了一个视图。此外,我在 Drupal 中通过 "r" (RFC 2822) 或 (D, d M Y H:i:s O) 设置了自定义日期格式,并将其用于该字段 "field_time"。该字段用作 pubDate。
日期字段创建而不是:
Wed, 01 Jul 2015 00:00:00 +0200
"german" 版本。
Mi, 01 Jul 2015 00:00:00 +0200
如果我对 "created" 日期做同样的事情,我会得到正确的英文输出。
我已经尝试将那个视图的 "field language" 设置为英文。 我还尝试以编程方式更改 tpl 行中的输出(淹没了我的 php 知识)。
它与 here 非常相似。
也许有人可以给我提示来更改该字段,在行模板或类似的东西中更改它。 提前致谢!
经过一些尝试和错误后,我通过字段级别的视图模板重写了字段 "field_time" 的输出。我从字段中获取原始值,将其转换为 RFC 2822 格式 "again",并以英语显示。
$rawdate = $row->field_data_field_time_field_time_value;
$unixdate = strtotime($rawdate);
print date('r', $unixdate);
之后我对其进行了一些修改,以使提要中的其他节点也只有例如node_created 通过 "rewrite if empty" 在视图 UI.
if (isset($row->field_data_field_time_field_time_value)) {
$rawdate = $row->field_data_field_time_field_time_value;
$unixdate = strtotime($rawdate);
print date('r', $unixdate);
} else {
print $output;
}
我不确定,如果那很干净。仍然欢迎提出建议。