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

“Add to home screen” website image

Hi guys,

A cool thing you can do with your website is to set the links which appear as shortcuts on your iPhone or iPad when you press “Add to home screen”.

This is a very cool feature if you have responsive design websites that people use constantly from devices.

Yes Apple is awesome. 🙂

Requirements: I would like to be able to change the images that appear when I use the feature “Add to home screen” my website on apple devices.

Continue reading