Frage

I need to loop through some content in a Sitecore solution (recursivly) and seek in all the fields in the item for references to media items. It is a Sitecore 6.5 solution, so out of the box it uses guid's to reference media items. But this is a solution that has been migrated to 6.5, so all media items references are not by guid's but a direct url to the media library.

I need to change this, so all links are referenced with the guid. Any idea on how best to do this?

War es hilfreich?

Lösung

I would follow the techniques described by Alex Shyba in his publish related media items article: http://sitecoreblog.alexshyba.com/2007/10/publish-related-media-items.html?m=1

To get an collection of all linked items, he uses:

yourItem.Links.GetValidLinks();

And...

Item itm = link.GetTargetItem();

Finally, you can test the links to see if they're media items using:

itm.Paths.IsMediaItem

  Apologies for the poor formatting, i'm posting from my phone :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top