Documentation for the MMPorter module.

About

The MMPorter Importer and MMPorter Exporter modules extend the NodePorter modules (documentation) to allow exporting Monster Menus page hierarchies and permissions to an XML description or import Monster Menus page hierarchies and permissions in addition to node content.

Installation

You must have the following modules installed for Drupal 6:

You must have the following modules installed for Drupal 7:

MMPorter has three separate modules that can be enabled independently as needed: MMPorter Exporter, MMPorter Importer, and MMPorter Importer UI.

Usage

Exporting Pages to XML

After enabling the MMPorter Exporter module, append /export to the end of any Monster Menus page URL. This will provide you with an XML file like the following:

<?xml  version="1.0" ?>
<pages xmlns='http://www.middlebury.edu/nodeporter'>
  <page mmtid="107765" user_mail="jdoe@example.edu" weight="0"
  theme="coursehub_site" hover="" rss="0" ctime="1297436151" cuid="1"
  node_info="0" previews="0" hidden="0" comment="0" max_depth="-1"
  max_parents="-1">
    <name><![CDATA[TEST 0101A: Reptiles and Amphibians]]></name>
    <alias><![CDATA[0101A]]></alias>
    <permissions>
      <write>
        <group cas_id="CN=amst0101a-s12-instructors,OU=Spring12,OU=Classes,OU=Groups,DC=middlebury,DC=edu"/>
        <user mail="jane.doe@example.edu"/>
      </write>
      <add_pages>
      </add_pages>
      <add_content>
        <group  cas_id="CN=LIS Liaisons,OU=General,OU=Groups,DC=middlebury,DC=edu"/>
      </add_content>
      <read>
        <everyone/>
      </read>
    </permissions>
    <pages>
      <page mmtid="107770" user_mail="jdoe@example.edu" weight="2"
      theme="" hover="" rss="0" ctime="1297436151" cuid="1" node_info="0"
      previews="0" hidden="0" comment="0" max_depth="-1" max_parents="-1">
        <name><![CDATA[Course Listing]]></name>
        <alias><![CDATA[about]]></alias>
        <permissions>
          <write>
            <group cas_id="CN=amst0101a-s12-instructors,OU=Spring12,OU=Classes,OU=Groups,DC=middlebury,DC=edu"/>
            <user mail="jane.doe@example.edu"/>
         </write>
          <add_pages>
          </add_pages>
          <add_content>
            <group  cas_id="CN=LIS Liaisons,OU=General,OU=Groups,DC=middlebury,DC=edu"/>
          </add_content>
          <read>
            <everyone/>
          </read>
        </permissions>
        <pages>
        </pages>
        <nodes>
          <node type="page" nid="4045" vid="4045" language=""
          user_mail="jdoe@example.edu" status="1" created="1297436151"
          changed="1304628961" comment="0" promote="0" moderate="0"
          sticky="0" tnid="0" translate="0" format="1">
            <permissions>
              <write>
              </write>
            </permissions>
            <title><![CDATA[TEST 0101A: Reptiles and Amphibians]]></title>
            <body><![CDATA[<p>Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Ut vitae nunc sed orci convallis posuere. Proin
euismod placerat tincidunt. Quisque sit amet neque sed eros
luctus lobortis. Maecenas posuere, sapien sit amet imperdiet
tristique, mi sem vestibulum arcu, et vestibulum sapien quam at
neque. Mauris tincidunt venenatis turpis quis tempor. In
malesuada fringilla pretium? Suspendisse pulvinar luctus libero,
at cursus mauris porta non. Phasellus in diam enim, et iaculis
orci! Quisque nisi tortor; sagittis id posuere et, blandit id
risus! Nunc volutpat dictum lacus fringilla fringilla?
Suspendisse placerat gravida sapien non scelerisque!</p>

<dl> <dt>Instructors:</dt> <dd><a
href="http://www.example.edu/john_doe">John Doe</a></dd> <dt>Location:</dt>
<dd>BIH 121</dd> <dt>Schedule:</dt> <dd>Monday, Wednesday, Friday from
9am-10:30am</dd> </dl>]]></body>
            <teaser><![CDATA[<p>Lorem ipsum dolor sit amet, consectetur
adipiscing elit.]]></teaser>
          </node>
        </nodes>
      </page>
    </pages>
    <nodes>
      <node type="course_metadata" nid="4046" vid="4046" language=""
      user_mail="jdoe@example.edu" status="1" created="1297436151"
      changed="1331563143" comment="0" promote="0" moderate="0" sticky="0"
      tnid="0" translate="0" format="1">
        <permissions>
          <write>
          </write>
        </permissions>
        <title><![CDATA[Reptiles and Amphibians]]></title>
        <body><![CDATA[<p>Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Ut vitae nunc sed orci convallis posuere. Proin euismod
placerat tincidunt. Quisque sit amet neque sed eros luctus lobortis.
Maecenas posuere, sapien sit amet imperdiet tristique, mi sem
vestibulum arcu, et vestibulum sapien quam at neque. Mauris
tincidunt venenatis turpis quis tempor. In malesuada fringilla
pretium? Suspendisse pulvinar luctus libero, at cursus mauris porta
non. Phasellus in diam enim, et iaculis orci! Quisque nisi tortor;
sagittis id posuere et, blandit id risus! Nunc volutpat dictum lacus
fringilla fringilla? Suspendisse placerat gravida sapien non
scelerisque!</p>]]></body>
        <teaser><![CDATA[<p>Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Ut vitae nunc sed orci convallis
posuere.]]></teaser>
        <field_short_name cck_field_type='text'>
          <value><![CDATA[TEST 0101A]]></value>
        </field_short_name>
        <field_term_id cck_field_type='text'>
          <value><![CDATA[term/test-spring-2011]]></value>
        </field_term_id>
        <field_term_label cck_field_type='text'>
          <value><![CDATA[Spring 2011]]></value>
        </field_term_label>
        <field_term_start_date cck_field_type='text'>
          <value><![CDATA[2012-02-13]]></value>
        </field_term_start_date>
        <field_term_end_date cck_field_type='text'>
          <value><![CDATA[2012-05-22]]></value>
        </field_term_end_date>
        <field_term_weeks cck_field_type='number_integer'>
          <value>15</value>
        </field_term_weeks>
      </node>
    </nodes>
  </page>
</pages>

As you can see, the <node> elements are the same as those generated by the NodePorter module, with the addition of

<permissions>
  <write></write>
</permissions>

elements. <page> contain lists of subpages in their <pages> element and nodes directly on the page in their <nodes> element.

Here is a simplified overview of the structure:

<?xml  version="1.0" ?>
<pages xmlns='http://www.middlebury.edu/nodeporter'>
  <page mmtid="" user_mail="" weight=""
  theme=" hover="" rss="" ctime="" cuid=""
  node_info="" previews="" hidden="" comment="" max_depth=""
  max_parents="">
    <name><![CDATA[Page title]]></name>
    <alias><![CDATA[page_slug]]></alias>
    <permissions>
      <write>
        <group cas_id="external_group_1234"/>
        <user mail="jane.doe@example.edu"/>
      </write>
      <add_pages></add_pages>
      <add_content></add_content>
      <read>
        <everyone/>
      </read>
    </permissions>
    <pages>
      <page>...</page>
      <page>...</page>
    </pages>
    <nodes>
      <node>...</node>
      <node>...</node>
    </nodes>
  </page>
</pages>

Importing Pages from XML via the UI

After enabling the MMPorter Importer and MMPorter Importer UI modules you will find an Import Pages menu option under Administer » Monster Menus. Enter either an mmtid or a path under which the pages and their content will be imported. Paste the XML you previously exported (or XML of a similar structure) into the form and submit.

The key attributes in the XML are the <node nid=""... and <page mmtid=""... attributes. If the nid attribute exists and matches an existing node, then the existing node will be updated with the contents from XML. If the nid attribute is empty, then a new node will be created with the contents from XML. Similarly, if the mmtid attribute exists and matches an existing page, then the existing page will be updated with the contents from XML. If the mmtid attribute is empty, then a new page will be created with the contents from XML.

Importing Pages from XML programatically

The MMPorter module is most useful when used programatically to bulk create/update content. Your custom scripts can simply call mmporter_importer_import_string($parentId, $xmlString) to import pages and nodes from XML. This function will return an array of the top-level page ids that were imported so that further reporting or updates can be applied.