When building a view I want to filter on Status but I get no clue what do select as filter value.

As my views 6 skills are rusty I report first then add a patch. The definition is given in hosting_site.views.inc

  $data['hosting_site']['status'] = array(
    'title' => t('Status'),
    'help' => t('The current state of this site.'),
    'field' => array(
      'handler' => 'views_handler_field_hosting_site_status',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
  )

which should use the labels somehow as done in

/**
 * Define the status types of a site
 */
function _hosting_site_status($node) {
  $status = (is_numeric($node)) ? $node : $node->site_status;
  static $labels = array(
    HOSTING_SITE_QUEUED => "Queued",
    HOSTING_SITE_ENABLED => "Enabled",
    HOSTING_SITE_DELETED => "Deleted",
    HOSTING_SITE_DISABLED => "Disabled",
  );
  return $labels[$status];
}
CommentFileSizeAuthor
#1 hosting-site-1997088-1.patch717 bytesclemens.tolboom
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

clemens.tolboom’s picture

Status: Active » Needs review
FileSize
717 bytes

We need at least the list of key-value pairs.

helmo’s picture

As we discussed in person, this needs a bit more info.

This patch introduces a function _hosting_site_status_options(),
But it still has to be used somewhere.

There probably needs to be some views handler that tells views where to look for possible options.

In the view hosting_platform_list we have to specifiy it like:
Hosting Platform: Status != -2

anarcat’s picture

Status: Needs review » Needs work

so i guess this is needs work..

Deciphered’s picture

So, as pointed out by helmo, you can already filter a Site based view, but with the numeric values as per the constants.

Obviously this isn't all that user friendly but I don't think the patch is necessarily the solution, I think it just needs an alternate filter handler to be used, I'll have a play and see what I can come up with.

Deciphered’s picture

Status: Needs work » Needs review

So, I take it back, the patch was absolutely the right way, as then it can be used by the 'views_handler_filter_in_operator' filter handler as the 'options callback'.

Edit: Forgot to add the updated view.

Deciphered’s picture

anarcat’s picture

Status: Needs review » Fixed

merged, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.