Step by Step Instructions Here (I Think)

Created on 15 June 2022, over 2 years ago
Updated 29 October 2023, about 1 year ago

Problem/Motivation

For those not familiar with config export / import, it is not intuitive and clear how this module works.

Steps to reproduce

Install the module. Follow instructions. Export. Be baffled as to what and where to import from.

Proposed resolution

Improve documentation.

Remaining tasks

Review my steps, to make sure they are clear and can serve as a starting point to help others.

User interface changes

None.

API changes

None.

Data model changes

None.

-----

Here's how I got to work, step by step:

  1. Go to the menu_export config page (Menu List tab.
    /admin/config/development/menu_export
  2. Choose the menu you want to export and click on Save configuration
  3. Move to the Export Tab and click on Export Selected Menu Links
  4. Go to your console and run drush config:export or drush cex
  5. This generates the config sync files, including the menu_export.export_data.yml file you want on a folder under your files folder. Look for the files/config_bunch_of_unique_characters_here/sync folder and you will now find menu_export.export_data.yml there.
  6. Copy this menu_export.export_data.yml file to the files/config_bunch_of_unique_characters_here/sync folder on your destination site.
  7. Go to the destination site and run drush cim --partial or drush config:import --partial and confirm that you want to import this config.
  8. Look at the command output to make sure it worked.
  9. Go to /admin/structure/menu/ to find your imported menu there :-).

It worked, but I got a few errors on the log of the importing site (see below), other than the error on the logs, everything worked fine.

Warning: Undefined array key "menu_name" in Drupal\menu_export\Form\MenuImportForm->submitForm() (line 70 of /xxx/web/modules/contrib/menu_export/src/Form/MenuImportForm.php)

Warning: Trying to access array offset on value of type null in Drupal\menu_export\Form\MenuImportForm->submitForm() (line 70 of /xxx/web/modules/contrib/menu_export/src/Form/MenuImportForm.php)

Warning: array_flip(): Can only flip string and integer values, entry skipped in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 312 of /xxx/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php)

Warning: Undefined array key "menu_name" in Drupal\menu_export\Form\MenuImportForm->submitForm() (line 70 of /xxx/web/modules/contrib/menu_export/src/Form/MenuImportForm.php)

Warning: Trying to access array offset on value of type null in Drupal\menu_export\Form\MenuImportForm->submitForm() (line 70 of /xxx/web/modules/contrib/menu_export/src/Form/MenuImportForm.php)

Warning: array_flip(): Can only flip string and integer values, entry skipped in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 312 of /xxx/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php)

Ps: Because of the errors in the logs, I decided to use Backup and Migrate module instead, which turned out to be more straightforward and simple for my needs, although it did mess a little with the order and hierarchy of the existing menu items when importing. Hope these instructions help others not familiar with config:export

πŸ“Œ Task
Status

Active

Version

1.0

Component

Documentation

Created by

πŸ‡«πŸ‡·France Carlos Miranda Levy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡­πŸ‡ΊHungary SunnyGambino Buj

    Thanks for the documentation! It saved me hours! I would like to suggest to place it into a README.md file into the codebase!

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    I was puzzled by all the steps in the README, and think it could be made clearer, by splitting it up into a normal configuration flow, and manual click to export/import like this :

    Configuration

    Select menu(s) to export under "Menu Export" (admin/config/development/menu_export).

    The menu(s) will now be included in the configuration flow, after running drush config:export in development, ready to be imported on the production site. For more about configuration, see https://www.drupal.org/docs/configuration-management/managing-your-sites... β†’ .

    Manual export and import

    1. Visit "Export" tab (admin/config/development/menu_export/export) and press "Export" button
    2. Copy exported configuration YAML to the target site.
    3. On the target site, visit the "Import" tab (admin/config/development/menu_export/import) to import menus
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    I have tested, and the items are not imported during a regular config import, luckily there's work being done on Drush commands.

  • πŸ‡ΊπŸ‡ΈUnited States jim_b

    6. Copy this menu_export.export_data.yml file to the files/config_bunch_of_unique_characters_here/sync folder on your destination site.
    7. Go to the destination site and run drush cim --partial or drush config:import --partial and confirm that you want to import this config.
    8. Look at the command output to make sure it worked.
    9. Go to /admin/structure/menu/ to find your imported menu there :-).

    Unfortunately in my testing, these steps are not entirely correct. I'm testing with Drupal v9.5.x.
    There is an additional step required, see below:

    When I do a partial import with my "menu_export.export_data.yml" file, which lives in: 'config-menu-test/':
    drush cim --partial --source=/config-menu-test -y
    The import says it is successful:
    [success] The configuration was imported successfully.

    But after clearing the cache and viewing the menu as in Step #9, unfortunately the menu is still not updated.

    The menu is only updated after going to:
    '/admin/config/development/menu_export/import'
    and clicking "Import Menu Links".

    Then viewing the menu (step #9) will show the updated menu.

    There should be a step between #8 and #9:
    Go to: '/admin/config/development/menu_export/import', click "Import Menu Links".

    Unfortunately this requirement to use the Admin GUI limits the usefulness of this module for automated deployments. I hoped just drush cim partial import would work by itself.

Production build 0.71.5 2024