Closed (won't fix)
Project:
Views (for Drupal 7)
Version:
5.x-1.6
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Apr 2008 at 15:42 UTC
Updated:
4 Aug 2010 at 18:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
mvcIn case anyone else is interested in using this, I should mention that the following code in the view template checks whether the current user has a given role (in my case, 'administrator'). This together with the $status field can be used to control which content is displayed.
Comment #2
mike booth commentedI tested this against an installed copy of 5.x-1.6 -- seems to work fine, just what I needed.
I do think it would be better to make this display "Yes/No", rather than 0/1. The field value may not be visible in *your* application, but in general when this field is added to a view it will be displayed. Best to avoid confusing digits in favor of recognizable words.
I'm not in love with the fact that the field is called "Published" on the visible UI and "status" in the DB and in the API. But this patch is consistent with the rest of Drupal in that usage, and I think that's fine.
Comment #3
sunThis patch has a chance to be included in 1.7, if you account for the mentioned changes.
Comment #4
kingandyDid this ever get advanced or included? I think all it would need would be a new function to handle converting 1/0 to Yes/No.
... and then a line in the node_views_tables() saying "'handler' => 'views_handler_field_yesno',".
For what it's worth, I'm in favour of the "Node: Published" label since it is consistent with the already available filter for this data.
Find attached a patch (generated by comparing old and changed files using Komodo Edit - I don't have a patch roller but apparently it's the same format). While I was in there I also changed 'sortable' to true, since I don't see any reason to prevent people from sorting on this field. This seems to work under Views 5.x-1.6 (which is apparently still the recommended release for 5.x).
Comment #5
kingandyPS: I'm not exactly sure how this will behave given a non-1/0 input - I figured it was safer to do nothing than set a default, but I don't know how Views would react to a handler not returning. But that's the beauty of developing with preconditions!
Comment #6
mvcThis patch works for me.
Comment #7
esmerel commentedAt this time, only security fixes will be made to the 5.x version of Views.