| 20:20 | MarcosCarballal[ | Hey all! I'm trying to export a few terms in taxonomies that I have populated by hand. I have tried using both the menu at localhost/admin/config/development/confi and `drush cex` to get at these terms, but terms do not seem to get included in that export. |
| 20:20 | MarcosCarballal[ | My understanding is that is happening because the terms aren't considered to be part of the configuration, rather they are treated as content. |
| 20:20 | MarcosCarballal[ | Is there a better way to approach this? Most of our taxonomies will only have 4/5 terms, but we may need support for 100+ terms in the future. |
| 20:22 | paul121[m] | > My understanding is that is happening because the terms aren't considered to be part of the configuration, rather they are treated as content. |
| 20:22 | paul121[m] | Bingo! That is correct |
| 20:57 | MarcosCarballal[ | Our lead Drupal dev pointed me to this module (www.drupal.org/project/structure_sync), which seems to allow us to export these terms. I just want to check that this seems like a good way to go about it |
| 20:59 | paul121[m] | Sorry had to jump off for a sec |
| 20:59 | paul121[m] | I had not heard of structure_sync, interesting |
| 21:00 | paul121[m] | We are a bit familiar with the default_content module which seems similar: www.drupal.org/project/default_content |
| 21:01 | paul121[m] | Another option may be to auto-create those terms in `hook_install()` |
| 21:01 | paul121[m] | (that's basically what these default_content/structure_sync modules do) |
| 21:03 | MarcosCarballal[ | Interesting, could I just make a reference csv file and write a `hook_install()` which reads in this csv and populates the appropriate taxonomies? |
| 21:04 | paul121[m] | since this is a custom module I think that makes sense. for a more general/contributed module it's not "best practice" to do this sort of thing |
| 21:04 | mstenta[m] | Hey! Just got back from picking up the kiddos - I second the `default_content` recommendation! |
| 21:04 | paul121[m] | yup, exactly |
| 21:04 | mstenta[m] | I haven't used it myself, but I know someone who has - for the exact same reason (taxonomy terms) |
| 21:05 | mstenta[m] | But `hook_install()` works too! Either way - `default_content` might be more "automated" - although I can't speak from experience |
| 21:06 | MarcosCarballal[ | I'll definitely check out the default_content module, I'm not sure that it has the "import/export" functionality that I need, though. |
| 21:07 | paul121[m] | Yeah. Just reading default_content a bit closer, it has built in support for drupal normalization and serialization - which is great when your content entities have many fields, different types, entity references, etc. But if your taxonomy is pretty simple, a simple csv or json list might be sufficient |
| 21:08 | mstenta[m] | Come to think of it... Marcos Carballal this might be helpful: github.com/farmOS/farmOS/blob/65879166fd |
| 21:09 | mstenta[m] | That's from farmOS 1.x (so might not work for 2.x!) but could serve as an example for loading from a CSV file |
| 21:09 | paul121[m] | if you need import/export support, you could make a `drush` command fairly easily too I think |
| 21:09 | mstenta[m] | In 1.x, the `farm_soil_nrcs` module imported a list of "STIR Operations" from this file: github.com/farmOS/farmOS/blob/7.x-1.x/mo |
| 21:09 | mstenta[m] | NOT into taxonomy terms... but maybe the CSV reading parts of that code would be useful at the very least |
| 21:10 | mstenta[m] | I'll dig up the other place where I know `default_content` was used... one sec... |
| 21:10 | MarcosCarballal[ | Well I have been using `drush cex` and `drush cim` to get a feel for what these config files actually look like. |
| 21:10 | MarcosCarballal[ | I was hoping for some magical `taxonomy.terms.{taxonomy_name}.yml` file or something similar. |
| 21:10 | mstenta[m] | github.com/mstenta/farm_nfa/tree/2.x/web |
| 21:11 | mstenta[m] | (that in this module: github.com/mstenta/farm_nfa/tree/2.x/web) |
| 21:11 | mstenta[m] | the module depends on `default_content`: github.com/mstenta/farm_nfa/blob/9c272b0 |
| 21:12 | mstenta[m] | so maybe that's all you need to do (export YML files, put them in the correct directory, and depend on `default_content`) |
| 21:13 | MarcosCarballal[ | By "depend on `default_content`)", do you mean that we should add `default_content:default_content` to our list of dependencies for the module? |
| 21:13 | mstenta[m] | I think that would be necessary in order for `default_content` to be installed and find your term YML files |
| 21:13 | mstenta[m] | but you could potentially put that stuff in a sub-module that you only turn on for initial install and then turn them off again... |
| 21:14 | mstenta[m] | if you don't want to have default_content running on prod |
| 21:14 | MarcosCarballal[ | Okay, stupid question, how would I install Drupal Module not present in the Admin > Extend section? |
| 21:14 | MarcosCarballal[ | I tried `drush en {moduleName}` earlier, but it said that it could not find the module |
| 21:14 | mstenta[m] | oh yea - if you do `composer require drupal/default_content` that will download it to `web/modules` |
| 21:15 | mstenta[m] | and then it will appear in Admin > Extend, where you can install it |
| 21:15 | MarcosCarballal[ | Awesome, I will make a note of that. |
| 21:15 | mstenta[m] | All of the above said... a simple CSV import via `hook_install()` would definitely be the lowest overhead overall - especially if you just have a list of terms to create, but those terms don't have additional metadata on them (like fields) |
| 21:16 | mstenta[m] | So those are the two ways you could explore :-) |
| 21:16 | mstenta[m] | Let us know what you go with! We've been talking about using `default_content` to create a `farm_demo` module - for prepopulating a demo instance with content to demonstrate to new users how things work |
| 21:18 | MarcosCarballal[ | Yeah, I will try to parse through the CSV code example you gave. I am a bit hesitant making a custom CSV driven solution, but that also has the advantage of being easily replicable. |
| 21:35 | skipper_is[m] | Anyone connected a sewage treatment plant up to their FarmOS/Sensor? That's this week's project! |
| 21:37 | paul121[m] | sounds messy 🤣 |
| 21:46 | mstenta[m] | Hahaha |
| 21:48 | mstenta[m] | @donblair did some stuff with depth sensors at one point (eg measuring stock/water tanks) maybe relevant? |
| 21:56 | skipper_is[m] | I'm trying to interface with the existing fault/alarm system on the plant, and to record rotation rates, and when the pumps are active that kind of thing |
| 21:57 | skipper_is[m] | It's all 24v though |
| 21:57 | mstenta[m] | Oh interesting |