Robert is a SilverStripe developer who cut his teeth on computer games, first hacking them together between classes at uni and then professionally at Sidhe Interactive, where he worked on games for the PlayStation2 and Xbox consoles. After leaving Sidhe to "go indie" and develop websites to raise capital, he found that he really enjoyed working with web technologies and decided to make a go of it. This is Robert's first time as guest writer and he is here to introduce us to his latest project: the Drupal connector module.
The Drupal connector has finally arrived! With this module you’ll be able to embed or import content from a site running on Drupal 5+ into your SilverStripe 3 site.
A lot of clients that we at SilverStripe HQ hear from already have an existing site, and unless the site is particularly small, they’re understandably not too keen on transferring the content over manually! It can be a massive task, involving either a web manager doing days’ worth of copy-and-pasting or a developer trying to decipher database schemas and writing custom database queries to export and import the data.
So the clever clogs over at SilverStripe Australia developed the External Content module that allows SilverStripe to connect to other content management systems and read the data in there. In an nutshell, the module allows you set up connections to any number of external sources and then either display that information in a page on the SilverStripe website or import it directly into the SilverStripe site as pages. If you’d like more information on this module, head to the GitHub page or this tutorial of how to create a new connector.
One connector that was missing was one of the most requested; Drupal. Drupal is a major player in the CMS space and a lot of sites are running on it, so consequently we get a fair number of potential clients wanting to migrate their content off their Drupal website easily and cheaply.
Drupal organises page content into Nodes which are roughly equivalent to SilverStripe’s SiteTree objects. There is one key difference however - Nodes contain no hierarchy information. They can be organised into a tree with one of two main methods, a taxonomy or a menu.
A taxonomy is a list of tags that can be nested to form a hierarchy. If a Drupal site uses a taxonomy to form a menu, then each entry in the menu tree is created as as a tag in the taxonomy. Every Node is assigned to its parent tag and appears nested beneath it in the site structure. A simple taxonomy used for a menu is shown below:
So as you can see, this looks very similar to SilverStripe’s tree. There is a slight distinction in that in SilverStripe every entry in the menu is a SiteTree (and therefore, is likely a page on the website), whereas in a Drupal taxonomy structure the non-leaf entries are just taxonomy terms. When viewing one of these “pages” on the site they will usually just list their child pages and no content.
A menu structure is much closer to the SilverStripe SiteTree model. Each Node can be placed into a menu, either as a top-level element or as a child of an existing element in the menu. There is still a separation between the menu item and the Node that is corresponds to, but that’s only an underlying code issue rather than a structural difference.
Though there are a few hoops you’ve got to jump through to allow your Drupal site to receive connections from external sources, although it’s all fairly straightforward.
First of all, you need to install and the enable the Services module. This module will allow Drupal to provide web services via a variety of interfaces (such as XMLRPC, REST, etc).
If you’re using 5.x you’ll need to specifically enable the Node, System Taxonomy and User services, so enable them in the Services module:
Lastly, enable the XMLRPC Server:
If you’re using Drupal 5.x or 6.x, then you’ll also need to create an API key. To do this, visit /build/services/keys. The domain can be anything you like.
Unfortunately there is a constraint in 5.x and 6.x that caps the number of nodes per taxonomy item that can be returned by a feed, and this can’t be exceeded without modifying the module. However, we can still increase it as far as it can go - visit /admin/content/rss-publishing and adjust the “Number of items per feed”.
If you are using Drupal 7.x, you also have the option to export by menus. To do this, you’ll need to install the Services Menu module and then enable the menu service:
Also it’s worth noting that you should create a new user just for the connector to use. If you do so, make sure it has all the appropriate permissions to use the services (and services menu) module.
This will add an “External Content” tab to the CMS. From within this tab you’ll be able to create two types of Drupal connectors - one for menus and one for taxonomies. They’re very similar, the only difference being that one requires the name of the menu and the other the id of the taxonomy.
If you’ve entered everything necessary (including the API Key and Domain for 5.x or 6.x), then you should see the tree of the menu/taxonomy appearing in the left tree view:
From here you can either import the data as it exists right now into SilverStripe pages (using the Import tab), or create an External Content Page and view the content on the site as it appears on the Drupal site - even if new pages are added.
You can start using the connector right now - you just need SilverStripe 3.0+, the External Content module, the Drupal connector module, and a Drupal site!
It’s still pretty rough right now - the importing process takes a long time and doesn’t provide any feedback, and it doesn’t pull any assets in with it. One of our internal teams will be doing a fair bit of work with this module in the coming months, too.