0

I have rudimentary Recycle Bin system based on Flags and unpublishing / republishing content. However, when republished, "Has new content" displays Updated.

I still want New and Updated for when there are new comments so I'm not sure of the best way to go about it.

Thanks.

1 Answer 1

2

You need custom code to achieve this. There's 2 things to know here:

Updated Status Logic

The logic for driving the New & Updated labels is based on the history table (which stores the last time a user viewed a node) & the node.changed column:

$changed = $this->get_value($values, 'changed');

$last_comment = module_exists('comment') && !empty($this->options['comments']) ? $this->get_value($values, 'last_comment') : 0;

if (!$last_read && $changed > NODE_NEW_LIMIT) {
  $mark = MARK_NEW;
}
elseif ($changed > $last_read && $changed > NODE_NEW_LIMIT) {
  $mark = MARK_UPDATED;
}
elseif ($last_comment > $last_read && $last_comment > NODE_NEW_LIMIT) {
  $mark = MARK_UPDATED;
}
return $this->render_link(theme('mark', array('type' => $mark)), $values);

Essentially, it's comparing when a user last viewed a node vs. when a node was last changed.

What isn't known, is what was changed (e.g. the publish status) so to implement some sort of exclusionary logic you're going to have to track the history of publishing/unpublishing to check if the last update was just a change in publish status (node.status).

Updated Status Display

Assuming you have that logic in place, it's possible to override the output a views field. Here you can extend the views_handler_field_history_user_timestamp class with your own custom class implementing a render() method that adds the logic to check whether the last change was only a publish status change. In the final step, you can use hook_views_data_alter to override the handler for the Has new content field.

2
  • Thank you for the info! Not as simple as I'd thought.. It will take me quite a while to 1. work out a good method and 2. implement it. I'll report back in the future. Aug 7, 2016 at 16:56
  • Yeah, a quick lookup to find a contrib module that tracks publishing history yielded nothing for me. I imagine it has to exist for people with complex publishing workflows. Anyway, once you solve #1, the rest should be easy.
    – Shawn Conn
    Aug 7, 2016 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.