Domanda

In the GUI it is possible to get the resources used by a page as shown by the image. Now I would like to get this information in the code behind so that I can modify only pages that are using a specific image. Where is this data stored?

Image showing related resources

È stato utile?

Soluzione

Disclaimer: I don't know how that specific functionality is implemented, so it is possible that there exist a simpler way to achieve the same results as my proposed solution.

Looking at SharePoint object model, the only way that comes to mind to achieve that is to work backwards - checking for each file if it has a relation to the original listitem.
The SPFile object exposes the BackwardLinks property which represents the list of files that "utilize" the current checked one.

This means that for example it is possible to use this property to check if a page layout is in use: the BackwardLinks property would include all pages that use the inspected layout.

I can only assume that the "related files" functionality works by accessing that property. Basically, when you use it on a file it scans the site collection for other files whose BackwardLinks collection contains a reference to the original one.

Anyway - to achieve your goal, modify only pages that are using a specific image it should be sufficient to check the BackwardLinks property on the SPFile instance representing the target image.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top