According to the NumericFilter.php file (L150)
if the definition allows for the empty operator, add it.
This module's main function nulls out the publish_on and unpublish_on fields when it runs, so it would be great if you could use that information in a view to collect all unpublished & unscheduled nodes.
Please add this to the field definitions so that you don't have to add a relationship to force it to "allow empty".
If there are relationships in the view, allow empty should be true
so that we can do IS NULL checks on items. Not all filters respect
allow empty, but string and numeric do and that covers enough.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3049134-5.allow_empty_in_views_filters.patch | 942 bytes | jonathan1055 |
| #5 | allow empty before.jpeg | 59.54 KB | jonathan1055 |
| #5 | allow empty after.jpg | 177.37 KB | jonathan1055 |
Comments
Comment #2
jonathan1055 commentedHi jklmnop,
This sounds like a useful addition. Is something that can be added via the admin views interface, then exported? If so, can you have a go at customising the scheduler view, then export and I will see how it works.
Jonathan
Comment #3
jklmnop commentedI believe the field definition setting "allow empty" is supposed to be in code somewhere, probably a class, but I'm not entirely sure. It does not appear to be a setting that can be set via the views admin interface.
The scheduler view already does the relationship workaround. I realized that after I figured out that relationships force "allow empty" availability on fields.
I've attached a copy of views.view.scheduler_scheduled_content.yml (the file uploader changed the name for some reason)
I've duplicated the main view but removed the author relationship and name field so you can see the lack of "is empty/is not empty" operators in the
publish_on/unpublish_onfields.Comment #4
adamevertsson commentedYes, oh yes! Please add this. This has been bugging me for so long. It's very annoying to have to do a workaround for this, every time I need a new listing of the content that is or isn't scheduled for publishing. Would really enjoy such an update to the module.
// Adam
Comment #5
jonathan1055 commentedHi @jklmnop and @AdamEvertsson,
I did some investigation and FilterPluginBase has this comment
So Scheduler can implement
hook_views_data_alter()to add the 'allow empty' filter setting. Here's a patch for testing which works for me - see screen grabs. However, this is not covered by any phpunit tests, so it will need your manual testing also to verify it.Jonathan
Comment #6
jonathan1055 commented@jklmnop @AdamEvertsson
Have you managed to test my patch in #5 yet? I would like to get this into the next release of Scheduler which will be in a few weeks time.
Thanks.
Comment #7
jklmnop commented@jonathan1055
I’m sorry for the delay, I explored this issue and posted this ticket for another person on my team.
I did let them know about your patch but I see that we never rolled it in our composer file.
Thank you for the help! I will test this patch on Monday.
Comment #8
jklmnop commented@jonathan1055
The patch applied just fine (Drupal 9.1.9 with Scheduler 8.x-1.x). I imagine it works the same on D8.
I created a new view and added Publish and Unpublish fields and verified that the "is empty"/"is not empty" options showed up without the use of a relationship.
Thank you!
Comment #10
jonathan1055 commentedThanks for testing, good to hear it worked for you without any problem.
Committed!
Comment #12
ladybug_3777 commentedJust adding a comment that I tried this patch on my Drupal 9.2 site and it works great. Thank you!
NOTE - I had to apply the patch via composer as it was not included in version 8.x-1.3 when I downloaded it....
Comment #13
jonathan1055 commentedHi ladybug_3777,
Pleased to hear that it works for you.
Yes, the patch has been committed to 8.x-1.x dev but I have not released 8.x-1.4 yet. That is coming very soon, see #3150881: Plan for Scheduler 8.x-1.4 release