0

I just started maintaining a pretty large Drupal website. The site has a playlist that lists songs. The content type for each song has a text field where the user types in the time the song was played. Yes, its a TEXT field, not a date field :( So by default in Views I have no way of exposing a filter with a BETWEEN operator. Ugh.

Is there any way I could possible convert this field to a date field so I can use the between operator? Or maybe there's some other work-around I could do? Thanks for any help.

4

1 回答 1

0

您最好的选择是使用自定义模块,在保存/加载节点时将该值存储在实际的 Drupal 日期字段中。

function mymodule_node_presave($node) {
  if ($node->type == 'whatever_content_type') {
    $node->actualdatefield[LANGUAGE_NONE][0]['value'] = date('Y-m-d g:i:s', strtotime($node->userdatefield[LANGUAGE_NONE][0]['value']));
  }
}

类似的东西。您希望通过内容列表页面(如发布节点)触发触发 node_save 事件的更新选项之一,以更新现有节点。

于 2012-08-16T15:20:00.473 回答