Sitecore fun fact #2

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

Sitecore fun fact #1

Hello,

I came across this funny fact today:

  1. If a parent item has an unpublished date set up, lets say today and you save the setting but you don’t publish the change to the web.
  2. Then you go to a child item and publish it.It will delete everything that sits under the parent item to the child but it will not show any warning message like: the version you try to publish will be not displayed. Is life fare ?!?! I don’t know. But it should be some kind of message(my opinion!?).
  3. The only error you will get is this “layout not found” which will make you crazy and will force you to start republishing layouts and sublayouts and eventually punch the monitor 🙂 (which I did, but this may not apply to all)

VP