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

Find content ID of the page a page assets folder belongs to

Vote:
 

When a new media is added we need to identify if this media item is part of a page assets folder and if it is we would like to get the content ID of this page.

We hook onto the PublishedContent-event to identify when a media file is added and form this we can probably find the assets folder by recursively calling ParentLink, but we have not found any way to identify which page this folder belongs to.

How can I find the page ID for a page folder?

Is there a better way of getting the page assets folder for a media file other than the recursive calls for ParentLink?

#82390
Mar 11, 2014 14:20
Vote:
 

I think that ContentAssetFolder.ContentOwnerID should contain reference to page or block to which it's "binded" (attached).

http://world.episerver.com/Documentation/Class-library/?documentId=cms/7.5/733f8ec8-86f5-f29e-c832-16e81bfe3e91

 

#82402
Mar 11, 2014 19:54
Vote:
 

Thanks Valdis, that seemed to do the trick!

ContentOwnerID seems to return an content guid. I used PermanentLinkMapStore.Find(Guid guid) as PermanentContentLinkMap to get the ContentReference to the page

#82437
Mar 12, 2014 11:45
Vote:
 

Permanent link map always remind me of some *low* level stuff I have to deal :)

What about content resolver?

var resolver = ServiceLocator.Current.GetInstance<IContentResolver>();
var ref = resolver.ResolveContent(guid);

    

#82439
Mar 12, 2014 11:55
Vote:
 

Aah, even better! :) Thanks again, Valdis!

#82440
Mar 12, 2014 12:09
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.