Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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];
}
Comment | File | Size | Author |
---|---|---|---|
#1 | hosting-site-1997088-1.patch | 717 bytes | clemens.tolboom |
Comments
Comment #1
clemens.tolboomWe need at least the list of key-value pairs.
Comment #2
helmo CreditAttribution: helmo commentedAs 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
Comment #3
anarcat CreditAttribution: anarcat commentedso i guess this is needs work..
Comment #4
Deciphered CreditAttribution: Deciphered commentedSo, 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.
Comment #5
Deciphered CreditAttribution: Deciphered commentedSo, 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.
Comment #6
Deciphered CreditAttribution: Deciphered commentedUpdated branch in sandbox: http://drupalcode.org/sandbox/deciphered/2001932.git/shortlog/refs/heads...
Comment #7
anarcat CreditAttribution: anarcat commentedmerged, thanks.