Problem/Motivation
Sometimes it is desirable to show unpublished content in lists, so admin users can preview things before publication. However, when the list is sorted on a node's publication date, unpublished nodes all have a publication date of zero and sink to the bottom. A more accurate depiction would be for unpublished nodes to appear at the top of the list, as if their publication date was the current time.
Proposed resolution
- Change the default value for unpublished content from 0 to 2147483647 (the maximum value the database field can hold). That will make views sort properly.
- In addition to the published_at node property, add a published_at_or_now node property that equals the REQUEST_TIME when no publication date has been set.
Remaining tasks
- Make sure this works.
- Commit it.
User interface changes
None anticipated.
API changes
When implementing hook_publication_date_alter(), if no publication date has been set then $published_at will equal the defined constant PUBLICATION_DATE_DEFAULT, instead of 0.
Data model changes
None anticipated.
Comments
Comment #1
jstollerFirst stab at a fix.
Comment #3
jstollerFix test.
Comment #4
jstollerPatch take two. Now with install function!
Comment #6
jstollerCleaned up the patch a bit and hopefully fixed the test error. Also updated the issue summary to reflect the chosen approach.
Comment #8
jstollerAnyone want to review and test this patch before I commit it? I don't think I broke anything, but...
Comment #10
jstollerPushed to dev. Change record published at: https://www.drupal.org/node/2646240