Recursive field traversal in Drupal

Categories Drupal

So say you have to build a custom sitemap for a Drupal 7 site that makes heavy use of Field Collections, and you need to recursively extract every item of a certain field type on a DíA” single entity for the sitemap. Oh, and you need to wholesale mlb jerseys be able to selectively transform some items in the process.

Yep, you guessed it – I’ve run across this one before. We had a series of content types + that used heavily-nested field collections and a custom rebooted! sitemap requirement for the images that good ol’ XML Sitemap just wouldn’t accommodate. So we built one.  🙂  Note wholesale nfl jerseys that this one was geared toward grabbing images and altering the Brightcove module’s thumbnails to conform to our sitemap code’s requirements.

 

  • Varsha Jain

    Hi, I want to add videos hosted on Brightcove added to the sitemap. Will this code work with it? Thanks in advance!!

    • arpieb

      When we implemented this, there was no way to add videos or images directly to the sitemap provided by XML Sitemap as it’s geared more towards entity or term landing page links. We created a menu hook to render our own sitemap just for images based on this spec:

      https://support.google.com/webmasters/answer/178636

      Not sure if there’s a video analogue for a standalone sitemap.

      TL;DR – yeah, you could use this to extract a list of Brightcove fields from nodes to generate a sitemap entry, I just don’t think you can integrate it directly with XML Sitemap.