People who code: we want your input. Take the Survey
6

Then don't use custom block types because they are stored in content entities. Use blocks storing only configuration. You can build a custom block plugin, even with a body field. See Custom block build function to display wysiwyg body text There are also some contrib options like Simple Block which is implementing a config entity for blocks.


5

Configuration management Deploying content types, fields, views, site settings (everything that is not content) from one environment (local) to another (stage, prod etc.) in Drupal 8+ works by exporting the currently active configuration (stored in the database) into YAML files. The most common approach is to simply export all your site's configuration at ...


4

Make sure you inject config.factory and then you need to use: $this->config ->get('my_custom_module.settings') ->get('display_debugging_info'); You can see that Drupal::config() is: public static function config($name) { return static::getContainer() ->get('config.factory') ->get($name); } So after injecting your service, the ...


3

Yes this is the expected behavior. Config import and export is really quite simplistic (uncharitably: dumb). All it is doing when you run a config operation is to look at the active state of the DB and the active state of the sync directory and make one look like the other. On config:import (cim) you are saying "make the DB match those files in the sync ...


3

That's exactly what the Features module is for. Syncing partial config across multi-site instances. The features module enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case. Features provides a UI and API for taking different site building components from ...


3

Yes, you can't create content before the relying config has been imported. That's a classic Drupal 8 paradox which has just recently been solved by a new hook: hook_deploy_NAME(&$sandbox). Update to the latest Drush and from now on run drush deploy as part of your deployment routine, which replaces the old drush updb && drush cim routine. Then ...


3

The settings form is hard-wired to only display the config field on the form if one of the following is installed: the Smart IP module, GeoAPI module, or the PHP geoip extension. Outside that you'll have to bypass the config form; if you're version controlling your config, make the change in the eu_cookie_compliance.settings.yml file; or use drush cset to ...


3

I've found that this sort of thing is because the config in your sync directory is not quite legitimate. My guess is that this is an issue on your dev and local environments too, not just staging. I've found that the cause of this issue is usually a result of one of two things: 1. Configuration files were manipulated manually and the configuration in the ...


3

Using Form API and Configuration are two fundamentally different things: A module configuration forms in Drupal are (usually) provided by that module extending ConfigFormBase. A “Form” is just a specially-crafted render array that on submit (and validate) calls methods on the Form controller class. A module author can do whatever they want in that submit/...


2

The best way in my opinion is to use git work flow. What we do to export content type configuration with fields between the environments is we take a git feature branch and create content type and it's corresponding fields in our local environment and make a drush cex. Now in the git branch we have only the configuration related to the particular content ...


2

The most common way to use a settings.local.php file that is outside of your git repo. Each developer can use this to setup their local environment with local DB, etc. I tend to have a settings.local.php.example file in the repo that dev can copy to their settings.local.php file. This file can contain any Drupal overrides you want, e.g.: As Leymannx said: $...


2

The trusted_host_patterns settings is only for the domain name used to access the site. The regular expression you use must not include neither the port used to access the site, nor any path. If you access the site using as localhost, then the setting you should use is the following one. $settings['trusted_host_patterns'] = array( '^localhost$', ); If the ...


2

That page seems to be a Views page, but there is no way of telling from the screenshot if you're using a special module to build those page or simply Views. If it's Views then you can Edit the particular View, it has the Title option for the Page, that's where you change it. You can find list of all Views under Structure on the top menu.


2

The first example ($config['system.date']['timezone']['default'] = 'Europe/London';) is the correct way to override config values in your settings.php file. It sounds like you've hit an issue noted in the config override system docs: Note that values overridden via $config within settings.php will not be viewable from the Drupal administration interface (...


2

The key for $config is the config name, not the module. This should work: $config['shield.settings']['shield_enable'] = FALSE;


2

The Drush 8 commands config:export (cex) and config:import (cim) accept a --no to prevent the actual import or export. This allows you to write an if statement in Bash. Here is an example: if drush config:import --no | grep file.settings; then # Do something echo "Found in diff"; fi In Drush 9 and 10, the return value $? will tell you if ...


2

To fix the issue include config in optional directory instead of install directory in your features module. It will then only install the config which are not present in the new site. Which will solve your issue. When I try to enable to the module I get a screen full of "unable to install" because the configuration already exists errors. Ok, I ...


1

Drupal does not check the configuration schema at runtime when the configuration is loaded - the configuration is assumed to be correct. The schema is used in the tests - when running tests, configurations are automatically validated against the schema to ensure they are correct. Presumably you have developed your module with tests, and by the time you make ...


1

Yes indeed. If you wish to carry the redirects around you should probably export Or manually create the file if they are not too many. I would recommend a csv file. You can check this for reference How do I export the list of URL alias into an excel or csv? Then I would write a simple drupal migrate process to re import them in any environment. If you use ...


1

I have done it like this. $node = \Drupal\node\Entity\Node::load($nid); $layout = $node->get('layout_builder__layout')->getValue(); $sections = $layout->getSections(); foreach ($sections as $key => $section) { $components = $section->getComponents(); foreach ($components as $component) { if ($component instanceof SectionComponent &...


1

It isn't configurable. You would be better served writing your own routine that executes on a regular interval and searches for temporary files whose creation age is greater than 10 minutes ago. The DRUPAL_MAXIMUM_TEMP_FILE_AGE constant is specifically intended to inform Drupal on when a file that has not yet been set to permanent should be removed. If you ...


1

As discussed in the comments the solution, in most cases, is to add the field storage to the config/install folder of the module specifying persist_with_no_fields: true. core/modules/block_content/config/install/field.storage.block_content.body.yml langcode: en status: true dependencies: module: - block_content - text id: block_content.body ...


1

In /sites/default/settings.local.php make sure you have $settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml'; You need to go to /sites/development.services.yml and turn off Twig's cache by adding Parameters: twig.config: { debug: true, auto_reload: true, cache: false } This is what mine looks like: # Local development ...


1

Best way to do this is make custom modules and add the specific yml files to config/install. This way you can just enable the module on other websites. A good way of working could be a custom module named custom_paragraphs with a .info file and a modules folder. Within this module all your submodules per paragraph type. custom_paragraphs custom_paragraphs....


1

hook_ENTITY_TYPE_view() is probably the most misunderstood/misused hook in Drupal 8, mainly because it behaves differently than it did in Drupal 7 so you will find many misleading examples which no longer work in the current version of Drupal. In short, hook_ENTITY_TYPE_view() is only called when the entity is being rendered - after the entity has been ...


1

This appears to update ancillary settings the same as the web UI: drush php << 'EOD' use \Drupal\Core\Form\FormState; use \Drupal\Core\Render\RenderContext; $v['parser']['id'] = 'league/commonmark'; $v['parser']['render_strategy']['type'] = 'filter_output'; #$v['parser']['id'] = 'michelf/php-markdown-extra'; #$v['parser']['render_strategy'...


1

This import is empty This error might occurs when the config directory is not configured in the settings.php. Check for the config directory settings in new site. It will mostly have a different directory configured. Change to the same folder path as in the old site.


1

Docs for installing default configuration in a custom module However, putting a role in the configuration of a module is probably a bad idea. I can't think of an example of a major contrib module that does this. Imagine this situation: you install the module, and then the role gets enabled. Next, the user adds some other permissions to the role (created by ...


1

Use hook_config_schema_info_alter(). function module_b_config_schema_info_alter(&$definitions) { $definitions['module_a.settings.api']['mapping']['additionl_one'] = [...]; }


1

For me: drush config-set "system.site" uuid etc9c055aetcetc Confirms change: drush cedit system.site Fix the shortcut error during configuration import: drush ev '\Drupal::entityManager()->getStorage("shortcut_set")->load("default")->delete();' Manually edited the system.site.yml, changing the UUID to match. After ...


Only top voted, non community-wiki answers of a minimum length are eligible