0

I want to display all versions published of an item in Sitecore. I'm working with master database because in Web database we have just the last version published.

How can I found this status:published version or not of the item?

I'm working with Sitecore 8.2 update 4 with SXA

Thanks

2

3 Answers 3

1

As mentioned by Marek, "all versions published" sounds weird as there will always be only one version published (per language).

But to give you an idea of how you can fetch this information from the master database: if you have an Item object called item, you could do something like:

foreach (var version in Sitecore.Context.Item.Versions.GetVersions(true))
{
    version.Publishing.IsPublishable(DateTime.Now, false)
}

This will loop through all versions of the item in all languages (that is the true parameter in GetVersions). For each version it will check if it is publishable today without taking note of the ancestors. This is just an example with the IsPublishable function - you have more functions available in publishing.

5
  • @ Gatogordo, 'version.Publishing.IsPublishable(DateTime.Now, false)' gives information if it's publishable ant not it's published and I didn't found any functions in publishing that's gives informations about published
    – user1032
    Commented May 9, 2018 at 15:03
  • What information are you looking for exactly? A history of published versions? The current one (this is in web)? Can you clarify the question..
    – Gatogordo
    Commented May 9, 2018 at 15:23
  • 1
    Yes I need to found the history of published versions. For example if the item have 3 versions cretaed in EN language. the first and second version were published and not the third. I want to got the information that these 2 versions was published and to found their content
    – user1032
    Commented May 9, 2018 at 15:50
  • Do you use workflow?
    – Marek Musielak
    Commented May 9, 2018 at 16:23
  • I'm using the out of the box sitecore Sample Workflow but using it we can get a workflow state(Draft, Approve, waiting approve) and not published.
    – user1032
    Commented May 10, 2018 at 8:05
0

In Sitecore only one version of an item in given language is published at a time.

If you have an item with version 1 in EN language, you publish it, then there is version 1 published in the web database.

If you then create another version, version 2, you publish it, then version 1 is not published anymore, only version 2 is published.

If you need to find all the published versions, just check what is in web database.

3
  • I want to find all the published versions but in the web just the last version published will be in the web database. How can I found for example version 1 if I published version 2
    – user1032
    Commented May 9, 2018 at 14:10
  • But version 1 is no longer published. Do you mean that you want to find an information which version was ever published in the history, even if only for 1 second?
    – Marek Musielak
    Commented May 9, 2018 at 15:17
  • Yes I need to found the history of published versions. For example if the item have 3 versions cretaed in EN language. the first and second version were published and not the third. I want to got the information that these 2 versions was published and to found their content
    – user1032
    Commented May 9, 2018 at 15:28
0

You can get detailed item wise publish report using Sitecore module "SITECORE PUBLISH REPORTING KIT" available on marketplace at https://marketplace.sitecore.net/en/Modules/S/Sitecore_Publishing_Reporting_Kit_SPRK.aspx

enter image description here

Your Answer

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

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