November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi Mark,
Did you find a solution to this? I'm interested in getting a URL to a block as well.
Mark
One key characteristic of blocks is that they have no public URL (that is a key difference between pages and blocks) meaning they can not be rendered on its own, instead are they rendered as parts of other content e.g. when used in a contentarea.
You can however get a preview or edit url to a block, in that case is the block rendered in the preview template.
The url can be retrieved from
UrlResolver.Current.GetUrl(blockLink, null, new VirtualPathArguments { ContextMode = ContextMode.Preview });
I'm trying to create a 'cross-reference' for a page where I show any content referenced by the page (pages, blocks, media and external links), and also any content referencing the page.
For content referenced by the page, I can use the following method to retrieve soft links:
Then for each SoftLink in the collection, I can obtain a link to the referenced content for blocks and pages as follows (sl is an instance of SoftLink) (UrlResolver.Current.GetUrl(sl.ReferencedContentLink) always returns null for blocks, but works for media and pages):
However, when I get referencing softlinks by using the following method:
The SoftLink's Url property now points to the current page which is correct as this is now the 'source' of the softlink, but now I can't get the URL for blocks, as UrlResolver.Current.GetUrl doesn't work for block content references.
So is there a way to get a URL to a block, just knowing its content reference?