Request for custom date fields in "profile" to be available to filter by in views, this could be handy if I want to create a view that will show users born between x and y date.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | views.diff | 8.41 KB | finfin82 |
Request for custom date fields in "profile" to be available to filter by in views, this could be handy if I want to create a view that will show users born between x and y date.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | views.diff | 8.41 KB | finfin82 |
Comments
Comment #1
merlinofchaos commentedWhen core starts storing this data in a format that is usable for sorting and filtering, Views will allow you tsort and filter on it. Until then, this is not possible. Your best alternative is to use something like content_profile to attach a node to a profile and use CCK. A second alternative would be to write some hook_user code to attach proper date fields to a user, but that's way more work than it is worth.
Comment #2
charlie-s commentedI'm on the same problem! I have uploaded files that should only be visible to users who have a variable (user_support_expiration) that is 'less than or equal to' today. This profile variable (date) is hidden to the user and is set by an admin when users create accounts. I will investigate merlinofchaos' suggestions. I don't mean to sound ungrateful, but it does seem like filtering by date would be a standard feature.
Comment #3
merlinofchaos commentedPlease allow me to quote myself.
Wanting it will not make it possible. Begging me will not make it possible. Fixing core is the only thing that will make it possible. Please read and comprehend. Core's profile.module sucks, and there's nothing Views can do about that.
Comment #4
charlie-s commentedMerlin, I'm certainly not begging or asking you to rewrite profile.module :)
For anyone interested, the date field is stored in the database table profile_values in whatever field id (fid) it's been assigned to, with a value that is *not* in date format. (ex: a:3:{s:5:"month";s:1:"1";s:3:"day"... etc.) So it's not as easy as grabbing this field and comparing it as <= today to get a bool response.
I believe writing some PHP to evaluate this as a date and including that check in the views header will do the trick. I will be testing this soon.
Comment #5
sittard commentedsubscribing
Comment #6
karens commentedYou can't evaluate it in PHP, you have to have a value that your SQL can understand for the Views query. The query is executed before your PHP code will have any chance to do anything, which is too late to do any filtering. I don't think there is any possible way to do this other than what Earl already said.
The good news is that I *think* this will indeed be fixed in core in D7 with Fields in core. The bad news is that that will not be backwards-compatible to D6, so it won't help you in D6.
Comment #7
finfin82 commentedHi I had the same problem and build a workaround in combination of the module birthdays which creates the table {dob} where all birthdays get synced with the profile-birthdate-field
so you need to install and configure the module birthdays first.
after that you can use my patch, which adds filter and sorting(sorting untested) options to the users birthdate-field in a new group called "dob"
.... i hope this helps somebody
btw: i know it looks a bit dirty ;-) but it should just give you some kind of direction
greetings finfin
Comment #8
alextronic commentedHi finfin82,Thanks for your patch, but, excuse my ignorace, how and where shall I apply that "diff" file? Can you explain in a few words for a noobie? I've applied patches before but not like this...
thanks again in advance. I just need to use the birthdays datefield in views.
Alex.
OK, so... I did it, I applied the patch, but it didn't work -- or at least I couldn't figure out how the "dob" group works; I tried with it, but nothing. Anyone who can explain to me how to use views with this patch on?
My problem is that I can't sort the date of birth from the Birthdays module in a View of users ... anyone found a solution please?
Thanks in advance
Comment #9
alextronic commentedfinfin82? anyone? ... ouch...
Comment #10
radj commented+1
Comment #11
charlie-s commentedYou certainly could evaluate it (or anything else you wanted to) in PHP. You just need to request this from the database directly.
Comment #12
Marko B commentedI see this is still not possible with drupal 6 and views 2, is core modified in drupal 7 to make this work?