Posts tagged msm

EE, MSM and Datagrab

Over the weekend, twitter user @audiopleb ran into issues importing data to Expression Engine MSM sites via Datagrab. This is something we have a huge amount of experience in back at the office. That is to say, migrating data between sites (Non-EE -> EE and EE -> EE) is something of a specialty of mine.

One of the issues I’ve noticed with Datagrab (indeed, other add-ons as well) is how they deal with MSM sites. Datagrab for example uses this parameter to do a lot of it’s internal MSM handling:

    $this->EE->config->item('site_id')

This seems to mean that if you are accessing the control panel via http://site_1/system, then site_id will always be 1. For some reason, possible depending not the version of EE/MSM/Datagrab, changing the site via the CP drop down does NOT update the site_id value (at least according to Datagrab). My workaround has been to access the CP via the secondary sites URL. For example, use http://site_2/system. This seems to get things where they want to be.

All you really need to do to make this happen is put a copy of /admin.php somewhere under site_2. I use this structure for my sites:

  • /ee_system/ - site_1 system
  • /html/ - site_1 web root
    • /html/sites/
      • /html/sites/site_2/
        • /html/sites/site_2/dashboard/index.php - site_2 version of admin.php

Edit the site_2 version of admin.php to point all the way back to your main EE System folder via the $system_path variable. Mine looks like this:

    $system_path = '../../../../ee_system';

This keeps things nice and relative for easy migrations. I’m sure there is a solid explanation for this occasional behavior, but every the I’ve hit it I have been deep into a time-sensitive work. Some day I would love to understand why this happens, and why my work-around (aka, dirty hack) seems to work so consistently.


• • •