Skip to main content

Blog Post

Using Third Party Wrappers

Chances are decent that at some point you've needed to provide some third party service with styling information so that they can have their service look as though it were part of your website. The types of services this could apply to could range widely from external e-commerce platforms to HR and other internal tools. Furthermore, they could either include this HTML directly or with a link to files that you host.

Normally setting this up is a manual (albeit not terribly difficult) process. Fortunately, the Third Party Wrappers module is here to take that load off of your shoulders.

The upgrade to Drupal 7 and then Drupal 8

Third Party Wrappers was originally created by Chris Johnson for Drupal 6. However, we here at Mediacurrent had need of that exact functionality for a Drupal 7 site - so we took the original module and converted it to Drupal 7. It worked like a charm.

Following that, I invested some of my contrib time and some time at the sprints at BADCamp 2014 further upgrading it to Drupal 8. This was a bit more difficult than the upgrade from Drupal 6 to 7, but it was a great learning experience.

That’s great, but how do I use it?

The module is very simple. After the normal install procedure, head to the configuration screen. This can be found through the menus or as a Configure link on the modules admin page.

A required Drupal admin text field labeled "Content marker" with help text below.

The main thing you’ll need to configure is the content marker. When you request a page with Third Party Wrappers, the module will actually perform a second request to the specified page in the background, back to itself as an anonymous user. It will then search the HTML output of that request, and split it into two around (but not including) the configured content marker.

For Drupal 6 & 7: You can insert the marker into any page. For example, let’s say you used node/1. Navigate to /third-party-wrappers/top/node/1 to see the content before the marker, /third-party-wrappers/bottom/node/1 to see the content after the marker, or to see the full output including the marker, /third-party-wrappers/all/node/1.

For Drupal 8: The module provides a simple page that lives at /third-party-wrappers. Navigate to /third-party-wrappers/top to see the content before the marker, /third-party-wrappers/bottom to see the content after the marker, or to see the full output including the marker, /third-party-wrappers/all.

Then you can simply View Source and copy/paste the HTML to provide the header and footer to the third party. Alternatively, they can simply include those paths directly, if you would like any changes made to update automatically and don’t mind the extra bandwidth/processing costs.

But what about changes to our theme?

A Drupal admin form showing three text fields.

The module has you covered. It locates any CSS or JavaScript file included in the page and caches them separately, in a folder and for a length of time that you define on the Third Party Wrappers configuration page. If the third party service is simply using the code you copied and sent to them, this will allow them to continue to directly reference the CSS and JavaScript files on your server(s) without the service needing to copy all of those files over as well.

That covers the history and usage of Third Party Wrappers. If you have any questions or concerns, feel free to leave them in the comments!

Additional Resources

Top Drupal 7 Modules: Winter 2014 Edition | Mediacurrent Blog Post
Introducing the Mediacurrent Contrib Committee | Mediacurrent Blog Post