November Happy Hour will be moved to Thursday December 5th.

Get the containing page URL on block content publish

Vote:
 

I've tried to use info from this blog http://world.episerver.com/blogs/Per-Magne-Skuseth/Dates/2013/8/Letting-your-blocks-know-where-they-are/
to collect info about containg page for the block being published, but this works only when it gets to the rendering point.

Is there a way of getting the URL of containing page of the block being published if the block is actually contained in the content area?

#163293
Oct 20, 2016 11:05
Vote:
 

What about this (code from Dejan's answer)?

var linkRepository = ServiceLocator.Current.GetInstance<ContentSoftLinkRepository>();
             
var blockLink = (currentBlock as IContent).ContentLink;
 
var referencingContentLinks = linkRepository.Load(blockLink, true)
                                            .Where(link =>
                                                    link.SoftLinkType == ReferenceType.PageLinkReference &&
                                                    !ContentReference.IsNullOrEmpty(link.OwnerContentLink))
                                            .Select(link => link.OwnerContentLink)
                                            .ToList();
#163445
Oct 20, 2016 15:37
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.