In the backoffice if a document has been saved but not published a little orange star is overlayed its icon in the tree. Via the APIhow can I tell if a document is Saved vs Published?
That does not appear to be what I am looking for. That appears to indicate if there exists a published version of the document. What I am looking for is if the current doc has a saved version that is newer than the published version. That is to say I want to know if that little orange star is there or not for this doc.
That does not appear to be what I am looking for. That appears to indicate if there exists a published version of the document. What I am looking for is if the current doc has a saved version that is newer than the published version. That is to say I want to know if that little orange star is there or not for this doc.
Having been testing this for a few days now. doc.HasPendingChanges() is not 100% accurate. I looked at the source code for this method and it figures this by comparing the doc's version date to the update date. If they differ by more than half a second it figures there are pending changes. This is neccesarily the case. If your server's are running a little slow during publish actions those two timestamps might vary by more than that. In fact during local dev I have frequently that this be the case.
@greengiant, you could write a custom method to query the database and check I guess. Not sure of the field names etc, as I don't have the Umbraco Database in front of me, but the basic logic would be to check if the version is the most recent one by selecting the top 1 from the revisions table ordered by date desc, and compare the IDs to see if they're the same?
How to distinguish between published / saved
In the backoffice if a document has been saved but not published a little orange star is overlayed its icon in the tree. Via the APIhow can I tell if a document is Saved vs Published?
Hi,
You can use the Published property on the Document object.
Document doc = new Document(id of the document);
bool published = doc.Published
Hope the helps you,
Richard
That does not appear to be what I am looking for. That appears to indicate if there exists a published version of the document. What I am looking for is if the current doc has a saved version that is newer than the published version. That is to say I want to know if that little orange star is there or not for this doc.
That does not appear to be what I am looking for. That appears to indicate if there exists a published version of the document. What I am looking for is if the current doc has a saved version that is newer than the published version. That is to say I want to know if that little orange star is there or not for this doc.
Possibly doc.HasPendingChanges(); might be what you want?
-Tom
Thank you. That appears to do the trick.
Having been testing this for a few days now. doc.HasPendingChanges() is not 100% accurate. I looked at the source code for this method and it figures this by comparing the doc's version date to the update date. If they differ by more than half a second it figures there are pending changes. This is neccesarily the case. If your server's are running a little slow during publish actions those two timestamps might vary by more than that. In fact during local dev I have frequently that this be the case.
@greengiant, you could write a custom method to query the database and check I guess. Not sure of the field names etc, as I don't have the Umbraco Database in front of me, but the basic logic would be to check if the version is the most recent one by selecting the top 1 from the revisions table ordered by date desc, and compare the IDs to see if they're the same?
Nice example of how Umbraco is constantly being refactored due to the needs of the users.
is working on a reply...