Skip to content

StructureSync

Kota Miura edited this page Nov 1, 2018 · 1 revision

How to Use Structure Sync for Modifying Taxonomy Terms

This page is an instruction for using "Structure Sync" to output changes in taxonomy terms (which normally only happens in the database) to a text file.

For general changes in configurations, drush config:export or drush cexallows us to save that changes in yml files. However, there is a limitation that changes in Taxonomy Terms, Block Configurations and Menues are exceptional and will not be exported as changes in the yml files. Structure sync module adds a functionality to export these changes to yml file. Here, we focus on saving changes in Taxonomy terms, but the procedure to keep changes in yml file is similar for block configutations and menu changes.

Sync Files and Commands

Sturcture sync uses a new file structure_sync.data which is saved under config/sync directory where all the other files used by drush config . Configuration changes in taxonomy terms, such as addition of new terms and changes in the weighting of terms will all be written in this file.

drush export-taxonomies and drush import-taxonomies are commands added by Sructure Sync and these commands will export changes in taxonomy terms from the part of database that is not recognizable by drush cst to the part which will be recognized. It's important, that these two commands DO NOT EXPORT TO or IMPORT FROM text files.

Therefore, when you see that there are some updates in structure_sync.dataafter git-pulling, you need to first do drush config:importor drush cimthen drush import-taxonomies.

If these two step procedure is too laborsome, please add and alias in your .bash_profile something like

alias drushcim="drush cim & drush import-taxonomies"

and

alias drushcex="drush export-taxonomies & drush cex"

Usage Example

Aim: Change the order of taxonomy term listing.

The item "I do not know" moved from the third in the list to the fourth. See below.

Beforecontenttypes_originalorder After contenttypes_originalorder

Procedure

To change the order of the listing of this Taxonomy term, we change the configuration of the weight of terms in the configuration by accessing [Sturcture > Taxonomy ] and click "List terms" button in the right side of "Software Artefacts".

taxonomyTerm_changeOrder

By moving the position of "I do not know" term to the last row by click & dragging this term, the order of appearance in the menu will become as desired. Save this configuration change.

At this moment, the change has only happened in the database, but checking the status by drush config:statusor drush cst will return "nothing changed, all in sync".

For changes in the taxonomy term in the database to be "recognized", we need one special command offered by "structure sync".

drush export-taxonomies

After issuing this command, you will see the difference in the database and the saved yml file by drush cst.

structure change detexted

Now, it is possible to use the frequently used command drush cex, which will write and update in the taxonomy term configuration in the file structure_sync.data.

export taxonomy change

Then check that that structure_sync.data.yml was updated by the above operations using git diff.

git diff

... then add, commit the change, and push it as a pull request!