13

I need to do a full site publish but there could be content, without workflow with changes that can't be published. How could I build a "report" with the list of items with changes that would be published with a Site publish. To make it "easier" we are still on 6.6

  1. I have tried the "compare servers" module, but it takes too long and end up failing.
  2. I'm thinking about Razl, but i'm not sure if it Supports 6.6 and gives any sort of report.
  3. Would you consider doing it at SQL level? How?
5
  • 1
    To me, it looks like the heading asks a different question compared to your actual question text. Do you want to find out the full difference between two Sitecore DBs? Or just the list of items that will be transferred on the next publish? Commented Oct 17, 2016 at 11:21
  • 1
    If I'm strict I want to know what will be transferred on the next publish. Comparing two databases implies part of the solution Commented Oct 17, 2016 at 11:27
  • It's worth bearing in mind that the differences won't match up 1:1 with what would go out in a full publish. An item might have publishing restrictions set on it, or be in workflow, and a publish wouldn't necessarily push these items out to the target db.
    – Kasaku
    Commented Oct 17, 2016 at 11:43
  • I'm pretty sure Razl supports 6.6 so that can get the comparison job done for you but it doesn't really have any reporting capabilities Commented Oct 17, 2016 at 12:14
  • 1
    I believe the new Publishing Service available in 8.2 has this capability out of the box with manifests. I would look into that especially if upgrade is on the roadmap. It is quite hard to do this in a bulletproof way with the traditional publishing engine.
    – Alex Shyba
    Commented Oct 18, 2016 at 1:56

5 Answers 5

15

I would go with Sitecore PowerShell Extensions. It supports your version as well.

My idea is to run query and process all items you want to check.

In the past I used something like this to compare revisions between master and web database:

function RevisionsMatch($itemToCheck){
    if($(Test-Path "web:$($itemToCheck.Paths.Path)")){
        $webItem = Get-Item "web:$($itemToCheck.Paths.Path)" -lang $itemToCheck.Language
        if($webItem -ne $null)
        {
            if($webItem.Fields["__Revision"].Value -eq $itemToCheck.Fields["__Revision"].Value){
                $true
            }
        }            
    }
    $false
}

How to use it

$items = Get-ChildItem -Path "/sitecore/content/Playground" | 
        Where-Object { (RevisionsMatch $_) -eq $false } 

As a output you get filtered items that have different revision number in master and web database

If you want to create a fancy report, here some blog post about creating one: http://blog.najmanowicz.com/2014/10/25/creating-beautiful-sitecore-reports-easily-with-powershell-extensions/

If you are not able to install any additional module on your instance, you can always output report on some aspx page using the same strategy with comparing revisions.

EDIT:

If you want to exclude items with publishing restriction from your results you could write filtering function (it takes an item as input and returns it without any modification if condition are meet, otherwise nothing will be returned)

function ValidatePublishingRestrictions($itemToCheck){
    if($itemToCheck.'__Never publish' -eq 1){
        Write-Host "Skipping item [$($itemToCheck.ID)] because of publishing restrictions"
    }else{
        $itemToCheck
    }
}

And do something like this:

$items = Get-ChildItem -Path "/sitecore/content/Playground" | 
        Where-Object { (RevisionsMatch $_) -eq $false } | 
        ForEach-Object { ValidatePublishingRestrictions $_ }

That way you will get only items that can be published.

Notice, I added logging there so you can read which items were excluded:

Skipping item [{F0A490C2-9DF8-47F6-8E94-85713FCAA4CA}] because of publishing restrictions

4
  • This answers my original question (i'm testing it), but as @kasaku commented, the item may not be published due to publishing restrictions. Do you know how to include that check? Commented Oct 17, 2016 at 12:43
  • I extended my answer with details about excluding items with publishing restrictions. Hope that helps. Commented Oct 17, 2016 at 15:06
  • 1
    I would also add Workflow check and check for lifetime field values.
    – Alex Shyba
    Commented Oct 18, 2016 at 0:07
  • 1
    Hi Alan, Following Alex's comments I have investigated a bit more, and instead of checking the value of the field "never publish" wchi only check one of the restrictionsI'm doing this: $itemToCheck.Publishing.GetValidVersion($date,$true,$database) This line is checking the different publishing restrictions like, item level, version level, period and publishing target. (To be honest, the publishingtarget check is not working for me) Commented Oct 18, 2016 at 15:28
4

This is very nice solution that I implemented in my project:

In the content editor the left margin of the content tree is known as gutter. In this area we can show a icon that can be used to display the status of item i.e published or not published. For this you have to create a Custom GutterRenderer Class:

public class PublishStatusGutter : GutterRenderer
{
    enum PublishStatus
    {
        Published, NeverPublished, Modified
    }

    private PublishStatus CheckPublishStatusOfItem(Item currentItem)
    {
        Database webDB = Factory.GetDatabase("web");
        Item webItem = webDB.GetItem(currentItem.ID);

        if (webItem == null)
            return PublishStatus.NeverPublished;

        if (currentItem["__Revision"] != webItem["__Revision"])
            return PublishStatus.Modified;

        return PublishStatus.Published;
    }

    protected override GutterIconDescriptor GetIconDescriptor(Item item)
    {
        PublishStatus publishStatus = CheckPublishStatusOfItem(item);
        if (publishStatus != PublishStatus.Published)
        {
            GutterIconDescriptor desc = new GutterIconDescriptor();
            if (publishStatus == PublishStatus.NeverPublished)
            {
                desc.Icon = "your icon";
                desc.Tooltip = "tooltip message";
            }
            else
            {
                desc.Icon = "your icon";
                desc.Tooltip = "your message";
            }

            desc.Click = string.Format("item:load(id={0})", item.ID);

            return desc;
        }
        return null;
    }
}

If you will add this class using sitecore rocks then it will automatically add a gutter entry in core database otherwise you have to create a entry on following path:

enter image description here

Now it will show you a icon in gutter for unpublished item. I hope this will help you. Please mark as answer if you found it useful.

4

It might be worth having a look into the publishing queue. This is the piece that keeps track of every change made in Sitecore and is used by the "Incremental Publish" option.

There is even an API to use:

IdList queue = Sitecore.Publishing.PublishManager.GetPublishQueue(startDate, ToDate, Context.CurrentDatabase)

The publish queue will give you a list of the IDs of items which have had a change made during the period provided in the parameters.

0

Depending on your resources and expected results... But in case you strictly rely on the result of such report, I would suggest another scenario:

  1. Make a copy of your web database + connect it with Sitecore as a next Publishing target, e.g. FakeWeb.
  2. Add new logging processor into the publishItem pipeline to report what was actually done with every single item.
  3. Make your full site publish into the new FakeWeb target and see the result :) .

The idea of PowerShell script is not bad, but will not provide 100% correct results until you will copy the whole publishing logic into the script. As was already mentioned you have to consider workflow and publishing restrictions. But there is another functionality that can affect the result as well (items removal, moving items, bucket items). Different languages brings the next complexity level as well...

0

you have to check in web DB for that

private string CheckPublishStatusOfItem(Item currentItem)
{
    Database webDB = Factory.GetDatabase("web");
    Item webItem = webDB.GetItem(currentItem.ID);

    //check if item exists on web database or not
    if (webItem == null)
        return "Item not yet published";

    //compare the revision field
    if (currentItem["__Revision"] != webItem["__Revision"])
        return "item is modified but not yet published";

    return "item is published";
}

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.