Hi,
I'm going to apologise straight away, because I'm sure that this problem is down to my own stupidity and not a problem with the module - but I'm stuck!
I'm using:
Date: 7.x-2.6
Views: 7.x-3.5
I have content type which uses a date field for a birthday. Now I want to create a view which shows a table of people sorted by their birthdays. BUT excluding the year. For example if the following people have the birthdays:
Bob: 5 November 1970
Jane: 8 May 1975
Dave: 11 January 1980
The correct sort oder of the people according to their full birthday is the same as above. But I want a list of birthdays as they occur this year: e.g.
Dave: 11 January
Jane: 8 May
Bob 5 November.
So I create a date format called month_day which will display the birthdays as:
Dave: 0111
Jane: 0508
Bob: 1105
And then sort the table or the view like this. But I have the problems:
- when I sort the table, it sorts by the full date (with year) and not the rendered output.
- there isn't any way to use the "sort" options in a view (not the table sort options) to sort by month & day only
I've tried the views_php module, but this really just doesn't work. If I add the field "$rows->field_birthday" I just get the row number as described in: #1740208: PHP only returns the node id
So sorry - but I'm really stumped and can't work out how to solve what must be a relatively simple and common problem.
thanks for all your help,
Rich
Comments
Comment #1
richH commentedHi guys,
anyone have some feedback on this - I'm still stuck :-(
Thanks
Rich
Comment #2
richH commentedHi again,
any help at all? Would really appreciate some support.
thanks
Rich
Comment #3
richH commentedHi again,
would love some help on this.
thanks
Rich
Comment #4
richH commentedHi,
After reading the post #1140896: Variable $row does not contain correct values ($data->_field_data does), I managed to find a work around, but to be honest this is a workaround and I think this problem really needs to be solved to make this module useful.
My view has the fields for the person's name and their birthday as well as the Views PHP field. The settings in that field are:
VALUE CODE
ENABLE CLICK SORT --> Sort using custom PHP Code
OUTPUT CODE
To get the sort to work you must get the month/day information in the VALUE CODE section. However in the OUTPUT CODE section I could get the code
print (int)substr($data->_field_data[nid][entity]->field_birthday[und][0][value],5,2);to work, but this didn't work in the VALUE CODE section. Therefore I use the node_lode function which works.A nasty solution, but it works!
Hope this helps,
Rich
Comment #4.0
richH commentedAdd versions of software being used
Comment #5
webatelier commentedwas looking for a way to FILTER by month only (still looking),
your request is about SORTING by month,
there's a cleaner solution to do this than #4,
just wanted to help you with your problem and maybe some others
Add a field with the date you want to sort on, choose a date formatter for that field that only displays the month (you can add a format is you want in admin/config/regional/date-time/formats, f.ex 'F' will display the full month, or 'December')
Now hide this field (Exclude from display)
For your view format choose 'table' and under the table settings => Grouping Field Nr 1 choose the hidden field that you configured before this step.
This will group the display per month ...
Comment #6
charlysole commentedBased on the comment # 4, I'm trying to create a filter for php views that from a view of nodes containing the field date_field only show in the list nodes that day and month match the current month and day. Especially useful for showing birthdays.
This is my code, but I can not understand why it does not work.
If someone could help me I appreciate it.