I'm using the Scheduler
module to schedule when certain nodes get published & unpublished. They are set to be "Promoted to the front page" and even after the Scheduler
unpublishes the content, it stays promoted to the front page where it still appears and leads to a dead link.
How can I automatically set the content to also get un-promoted from the front page when it gets unpublished?
I also submitted a feature support request.
My front page is the default front page that comes with Drupal 7. I understand, that if I had my own view, I could select what kind of content gets displayed. But how can I do this with the Drupal 7 news feed?
Note: With mchar's suggestion, I came up with follwoing patch:
--- scheduler_orig.module 2016-02-20 12:52:02.002658565 -0800
+++ scheduler.module 2016-02-20 12:50:57.174657579 -0800
@@ -20,6 +20,20 @@
define('SCHEDULER_DATE_LETTERS', 'djmnFMyY');
define('SCHEDULER_TIME_LETTERS', 'hHgGisaA');
+/** [inserted by Ron 02/20/2016] - to automatically unpromote a node as it gets unpublished**/
+/**
+ * Implements hook_node_presave().
+*/
+function my_module_node_presave($node) {
+ $was_published = !empty($node->original->unpublish_on);
+ $now_is_unpublished = empty($node->unpublish_on);
+
+ if (!$node->is_new && $was_published && $now_is_unpublished) {
+ $node->promote = 0;
+ }
+}
+/** [/inserted by Ron 02/20/2016] **/
+
/**
* Implements hook_permission().
*/