Hello,
Publish with related item will not publish the children of the related item.
Example: Carousel item on the homepage which has a data source a item from a bucket.
- Homepage Carousel
- Slide 1
- Slide 2
- Slide 3
If you publish your home page with related items but your changes are only on the slides SURPRISE it won’t publish the slides.
This can be easly fixed with a custom pipeline.
Just replace the sitecore existing pipeline code with your custom -> Sitecore.Publishing.Pipelines.GetItemReferences.AddItemLinkReferences
public class AddItemLinkReferences : GetItemReferencesProcessor -> GetReferences()
private System.Collections.Generic.IEnumerable<Item> GetReferences(Item item, bool sharedOnly)
{
Assert.ArgumentNotNull(item, "item");
System.Collections.Generic.List<Item> list = new System.Collections.Generic.List<Item>();
ItemLink[] source = item.Links.GetValidLinks();
source = (from link in source
where item.Database.Name.Equals(link.TargetDatabaseName, System.StringComparison.OrdinalIgnoreCase)
select link).ToArray<ItemLink>();
if (sharedOnly)
{
source = source.Where(delegate(ItemLink link)
{
Item sourceItem = link.GetSourceItem();
return sourceItem != null && (ID.IsNullOrEmpty(link.SourceFieldID) || sourceItem.Fields[link.SourceFieldID].Shared);
}).ToArray<ItemLink>();
}
System.Collections.Generic.List<Item> list2 = (from link in source
select link.GetTargetItem() into relatedItem
where relatedItem != null
select relatedItem).ToList<Item>();
System.Collections.Generic.List<Item> list3 = new List<Item>();
foreach (var itemS in list2)
{
list3.Add(itemS);
if (itemS.HasChildren)
{
list3.AddRange(itemS.Children);
}
}
foreach (Item current in list3)
{
list.AddRange(PublishQueue.GetParents(current));
list.Add(current);
}
return list.Distinct(new ItemIdComparer());
}
I am open for suggestions if you have a better solution.
Thank you,
Vio