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.
Many of the module that use the Date API allow for filtering content based on the dates. Example, filter all content that occurs in the future, or between these dates.
For this module, I would like to be able to filter on things such as is the node open today, currently (the current time is between the open and close times), or will be opening/closing in the next 'x' hours.
Comment | File | Size | Author |
---|---|---|---|
#23 | office_hours_readme_txt.PNG | 20.96 KB | Kanat Ospanov |
Comments
Comment #1
johnvAdding this to the generic issue #696262: Show Status 'Open/Closed (now/today/soon)' in Views
Comment #2
johnvRe-opening this issue, since the issue mentioned in #1 refers to 'showing' not 'selecting' the status.
Latest -dev version contains Views 3 support.
The 2 Filter-handlers in the /includes directory are not converted yet, and should be able to perform this task.
(ATM they are disabled by commenting the out in the .info file.)
Patches are welcome.
Comment #3
johnvSee also #1945368: Integrate with Search API / Apache Solr
Comment #4
adelka CreditAttribution: adelka commentedsubscribe
Comment #5
alayham CreditAttribution: alayham commentedI am achieving "now open" filter in views using a views_php filter with the following code
If you use minutes, you need to add them to the code.
Comment #6
FuXXz CreditAttribution: FuXXz commentedAny plans to implement an open now / closed now Exposed filter in views?
Or is there a other way to get this function? Can the result from the views_php module exposed? Or can any other moudel read it? Maybe Rules? So is it possible to unpublish or fill a other field if the views_php filter return false?
Comment #7
johnvThis commit adds a filter with options: closed/open now/open today.
Comment #8
FuXXz CreditAttribution: FuXXz commentedThank you for the commit.
If i try to add filter i get an Ajax error:
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: ../admin/structure/views/ajax/add-item/navigation/default/filter
StatusText: Internal Server Error
ResponseText:
In addition there is an error in the log:
Notice: Undefined index: aliases in office_hours_field_views_data_alter() (Zeile 22 von ../sites/all/modules/office_hours/office_hours.views.inc).
Comment #10
johnvAbove commit is a new try.
Comment #11
FuXXz CreditAttribution: FuXXz commentedThis johnv is awesome.
It works better, i can add the filter now but it can only filter the "open" nodes.
The closed dont work.
Bothe Filter display Error:
Notice: Undefined index: und in office_hours_handler_filter_open->post_execute() (line 115 of .../sites/all/modules/office_hours/includes/office_hours_handler_filter_open.inc).
Warning: Invalid argument supplied for foreach() in office_hours_handler_filter_open->post_execute() (line 115 of .../sites/all/modules/office_hours/includes/office_hours_handler_filter_open.inc).
Notice: Undefined index: und in office_hours_handler_filter_open->post_execute() (line 115 of .../sites/all/modules/office_hours/includes/office_hours_handler_filter_open.inc).
Warning: Invalid argument supplied for foreach() in office_hours_handler_filter_open->post_execute() (line 115 of .../sites/all/modules/office_hours/includes/office_hours_handler_filter_open.inc).
Comment #12
johnvYeah, the current version is very basic:
- you must use nodes. Not other entites, not revisions.
- you must not translate the field (hence the 'und') Please check the database which language you use. Do you use translation? Content Translation? Entity Translation?
I'll see what I can do. Please answer the above questions.
Comment #13
FuXXz CreditAttribution: FuXXz commentedI installed the module and did no translation to it, but i use german language in the frontend. English for backend / Admin.
The vies show only node.
But i can't follow you which language my database is, where should i look ?
Now i deactivated locale module, deinstall it, reinstall office hours, create new contenttype, new office hour field, created a new view for nodes only. Now there is no error.
BUT the closed nodes still not visible if the filter is selected.
Comment #15
johnvTry the next update. It fixes the language problem and the selection problem.
Comment #16
johnvComment #17
FuXXz CreditAttribution: FuXXz commentedSame Error, closed nodes not displayed. I will trie again a fresh Drupal
Comment #18
johnvREmoving and re-adding the filter from your view might help (save inbetween)
Comment #19
FuXXz CreditAttribution: FuXXz commentedNo Change :( Same Error and behavior with 7.x-1.3+16-dev
Comment #20
FuXXz CreditAttribution: FuXXz commented7.x-1.3+17-dev works. I will try with locale and l10update etc.
Comment #22
sunil khan CreditAttribution: sunil khan commentedHello guys,
I have a problem
i have created new content type for tenders with following fields:
Title,
Files,
start date,
close date,
status ( open/close)
In view i want to apply following filter.
Between open and close date status will be open and i want to change status to close at closing date.
Comment #23
Kanat Ospanov CreditAttribution: Kanat Ospanov commentedHi,
Exposed filter does not work with open now \ closed now.
Drupal 7.64 Office hours 1.8
I see readme.txt, when will it be possible?