Opticon Stockholm is on Tuesday September 10th, hope to see you there!
Opticon Stockholm is on Tuesday September 10th, hope to see you there!
Check out softlink class in api to get references.
http://world.episerver.com/documentation/Class-library/?documentId=cms/8/2244434
That will give you a list of softlinks that contain pagelink as property. Use UrlResolver to get the url from that...
Hi Jonathan,
If you're using the latest version of EPiServer CMS, you can try the following code:
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>(); var content = contentRepository.Get<ImageData>(new ContentReference(87)); var references = contentRepository.GetReferencesToContent(content.ContentLink, true).ToList();
I used IContentSoftLinkRepository for Blocks and Pages, but it doesn't return correct results for Assets.
Great - but how would you dynamically know what Data Type the asset is? For example Video, Pdf, Image etc for this bit of the code: var content = contentRepository.Get<???>(
new
ContentReference(87));
.Get<MediaData>(mediaReference) as Image data
Or
.Get<MediaData>(mediaReference).MimeType
are two ways to get what type of media content you get...or use IContent like Dejan says if you don't even know if it is media.
Hi, These are all great replies and work - unfortunately it is very slow as I have lots of assets and lots of pages - it takes about 1 minute to get all the data back.
I think ill give this idea a miss - but thanks for all your help guys,
Jon
Hi,
Is there a way in c# to find the page(s) that a certain asset such as an image is on albeit a page or block on a page. Ideally I would like an asset search library and allows the user to click on the a link that will take them to the image on the page.
Thanks
Jon