1

I want to display a different "Submitted by" message for content that has been updated, and thus has multiple revisions.

How can I tell if I'm on the original revision, or if there are multiple revisions?

1 Answer 1

2

NodeStorage::revisionIds() will let you retrieve all revisions of a node which will let you compare against the current node's version.

 // Retrieve all vids.
 $nid = 123;
 $node = Drupal\node\Entity\Node::load($nid);
 $vids = \Drupal::entityTypeManager()->getStorage('node')->revisionIds($node);

 // Does the original node's vid match the current node's vid?
 return (reset($vids) == $node->vid->getString());

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.