Quantcast
Channel: Drupal Servers - Site News
Viewing all articles
Browse latest Browse all 10

Drupal Servers is now running Drupal 7!

$
0
0

Drupal Servers is now broadcasting to you live on Drupal 7! It is also now sporting a fancy new look with a custom Responsive Drupal theme that I am calling Agnostic, which I created as a sub-theme for Fluid Baseline Grid. FBG is a Drupal 7 theme that I contributed to Drupal.org as a proof of concept originally for bringing a very lightweight responsive theme to the Drupal CMS, but has spawned into my favorite theme I have developed so far. Feel free to start browsing Drupal Servers on your phone, tablet, or TV. It should be offically device agnostic!

I have been running the Drupal Servers website since Drupal 5 was the current release, and after Drupal 6 was released, I decided to relaunch the site on a fresh install of Drupal 6. There were a lot of changes I wanted to make to the existing site, and upgrading wasn't even in my mind on that migration. I did not have a ton of content, so it was easy enough to recreate it all manually the first time around. After much internal debate with myself, I have done the same this time around for the migration from Drupal 6 to Drupal 7, but without the manual creation of content part at the end. That part was going to be handled by the Feeds module this time, which I would be using to import all of my old content back to the site in Drupal 7. The main reason I didn't just upgrade this time around wasn't a ton of new features that I wanted to add though, it was mainly due to the fact that I had some fairly major issues with the upgrade process from Drupal 6 to Drupal 7. That's for another post, but the following is how I was able to successfully keep all of the content I have added to Drupal Servers over the years, aside from the Fivestar ratings that were accumulated, and comments, which were in some cases spam that made it through Mollom anyway. 

Export the Old Data from Drupal 6

My first task was figuring out a way to export my existing content out of my Drupal 6 website and into a format that could be easily imported into Drupal 7. I had already researched the best method for importing content after trying a few other modules, but in the end I chose the Feeds module to do the importing, as it could handle several data formats such as CSV and XML. My first idea was to use a CSV file, as I figured that would be the easiest to import, and then it dawned on me, the Views Bonus Pack! I remembered that it was very easy to setup a CSV export with Views Bonus Pack's Export module, and since my site was mainly a bunch of fields and a handful of content types, I figured it would be the easiest route to Drupal 7 for my content.

After building the views I needed for each content type and setting them to unlimited nodes, I setup Views Bonus Export to download a CSV file for each content type, which would export all of my existing data into a handy file that I could import into Feeds in Drupal 7. After a few tries, I was able to get all the data I wanted, or so I thought anyway. It turns out after importing the data into Feeds as a CSV, I quickly found out that not everything I needed was being exported, most importantly, any additional HTML I had in the body of my content was not exported into a CSV field. After some thought, I figured I would try giving the XML export format a try. That was the key to the castle. I was able to now export the full body, html and all, with ease into an XML file. My main concern now, was how to map the XML fields, as I had never done that before. Luckily it was not as hard as I thought.

Import the Old Data into Drupal 7

One important note before importing any of your content is that if you have multiple tags for your content, you are going to want to install the Feeds Tamper module, which will allow you to explode the values of that field programatically on import. Otherwise, you are going to have some funky looking categories on your site. This also goes for text fields with multiple choices. Feeds Tamper is very handy. Also, if there is any change in your files directory path, you are going to want to find and replace in your XML file to change the file location value to the new directory. This goes for files and images alike. You can also setup a find and replace on import with Feeds Tamper, which is pretty handy if you plan on constantly importing your content with XML.

Now that you have your data massaged, or Feeds Tamper doing the work for you on import, you are ready to start mapping your fields. Originally I had thought that a CSV would be easiest to import with, but the body field didn't contain all the additional markup I needed. Now I am using the XML format, which is much different, and relies on XPath to parse data within the Feeds module. For this, you are going to need the Feeds Xpath Parser module. Once installed, you will have some additional options available within your Feeds Importers settings within the Parser section. Choose the XPath parser, and we are one step closer to the finish line here.

Next, the Xpath Parser needs to have fields mapped within the Node Processor Mapping section, each of which will correspond to fields in your Drupal content types. These mappings are setup in the format of Xpath Expression and Target. The Xpath Expression can be selected from the dropdown that says "Select a Source". You will then choose a Target from the dropdown which says Choose a Target. This target will be your field within your content type. Note, if you are not seeing any fields here, you have not configured your Feed's node processor settings properly, and have probably not selected a Content Type to map to. For this example, my Content Type is Drupal Themes. After setting up your mappings in this section, they should look something like th following screenshot.

Feeds Xpath XML Parser Mappings Screenshot

Sorry, you aren't done yet, but you don't have much farther to go! The final step to this mapping configuration is to setup the actual Xpath Expression, which is done in the Xpath XML parser settings section. There you will find all of the indivudal mappings that you setup, which a text field to input your Xpath for each XML value you want to import. This took me a little while to figure out, mainly because I didn't know Xpath expressions, but after doing a little bit of Googling and reading up on it a bit, it was fairly easy to figure out. You basically have to look at the XML file in a browser or text editor, and figure out the structure of the XML file. My file was broken down into <node> sections, which was used as my XPath Context. I found out through my Googling that the proper way to setup the Context is with two slashes prior to the value, so in my example, the Context was //node. From there, it was very easy to figure out the value of each field, as they were merely what was the XML tag for the value. So, my screenshot field of <screenshot> was an Xpath Expression value of just, screenshot. Below is a screenshot, for lack of a better word, of what some of my final Xpath XML parser settings were.

Xpath XML Parser Settings Screenshot

Now you have all the XML files exported, you have all the import mappings setup, and it's time to import that content! I am not going to lie, you will probably not get it all migrated properly on your first try. In fact, to get it all right, it took me several tries to end up how I wanted it. In the end I was able to export over 250 Drupal themes, and over 100 Drupal modules, along with a handful of other pages and articles to XML files. Then I was able to use the Feeds module to setup an XML import routine to import all of my existing content into my new Drupal 7 website for Drupal Servers from those files. I hope you enjoy the new Drupal Servers website, and I hope that this layman's Drupal 6 to Drupal 7 migration tutorial helps you if you end up having as many problems as I did trying to upgrade to Drupal 7 from durpal 6. Good luck out there!


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images