开发者

Drupal Exposed Views Filter custom date

I have a date filter that I have exposed on my view. I want to make the interface more user friendly and tighten up the look of it. Instead of selecting a date I would like to select from the开发者_如何学Go following options.

  • The last day
  • The last week
  • The last year
  • All

This would then filter on the date field. Is this possible? How would you go about doing this?


The proper way to do it is to alter the form in a custom module using hook_form_alter:

function YOURMODULE_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'views_exposed_form') {
    $view = &$form_state['view'];
    $display = &$form_state['display'];
    if ($view->name == 'YOURVIEWNAME' && $display->id == 'YOURDISPLAYID') {
      //Alter $form here, use dpm($form) to inspect it.
    }
  }
}

$form is an array describing the form, using Drupal Form API. You can inspect this array using dpm from the Devel module.


It is possbile, but you will need to write your own module for that.

That module would use the method called "Form Alter" to change the form. Try starting here http://drupal.org/node/157253

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜