Skip to main content
added 1843 characters in body; edited title
Source Link
paul cappucci
  • 1.3k
  • 2
  • 23
  • 42

Update. 4k4 comment below put me in the right place. According to this post https://drupal.stackexchange.com/a/266393/58880. I needed to apply addCacheableDependency

\Drupal::service('renderer')->addCacheableDependency($variables, $config);

Since I am using hook_node_view. I changed $variables to $build

\Drupal::service('renderer')->addCacheableDependency($build, $config);

Now when I click the checkbox the value of chechbox is correct and its not coming form the config. The text banner is displayed on all nodes. My change is below.

function my_form_configy_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {

  $config = \Drupal::config('my_form_configy.settings')->get('checkbox');
  // add the cache tag, so that the output gets invalidated when the config is saved
  \Drupal::service('renderer')->addCacheableDependency($build, $config);

I am trying to understand what this does? Where is the value of 'checkbox' being stored now. Its not in my modules settings.yml file because I have not exported the configuration yet. Is it stored in browser cache, or Drupal cache? Since I am developing I disabled all twig and drupal cache in settings.local.php with.

$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

The Devel module is not using addCacheableDependency

Clicking the checkbox 'Display $page array' The dpm feature works immediately.

function devel_page_attachments_alter(&$page) {
  if (\Drupal::currentUser()->hasPermission('access devel information') && \Drupal::config('devel.settings')->get('page_alter')) {
    dpm($page, 'page');
  }
}

Update. 4k4 comment below put me in the right place. According to this post https://drupal.stackexchange.com/a/266393/58880. I needed to apply addCacheableDependency

\Drupal::service('renderer')->addCacheableDependency($variables, $config);

Since I am using hook_node_view. I changed $variables to $build

\Drupal::service('renderer')->addCacheableDependency($build, $config);

Now when I click the checkbox the value of chechbox is correct and its not coming form the config. The text banner is displayed on all nodes. My change is below.

function my_form_configy_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {

  $config = \Drupal::config('my_form_configy.settings')->get('checkbox');
  // add the cache tag, so that the output gets invalidated when the config is saved
  \Drupal::service('renderer')->addCacheableDependency($build, $config);

I am trying to understand what this does? Where is the value of 'checkbox' being stored now. Its not in my modules settings.yml file because I have not exported the configuration yet. Is it stored in browser cache, or Drupal cache? Since I am developing I disabled all twig and drupal cache in settings.local.php with.

$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

The Devel module is not using addCacheableDependency

Clicking the checkbox 'Display $page array' The dpm feature works immediately.

function devel_page_attachments_alter(&$page) {
  if (\Drupal::currentUser()->hasPermission('access devel information') && \Drupal::config('devel.settings')->get('page_alter')) {
    dpm($page, 'page');
  }
}
I guess that's what you actually wanted to ask
Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

How to add Configuration usinghave config from a ConfigFormBase immediately take effect without needing to export it?

added 17 characters in body
Source Link
paul cappucci
  • 1.3k
  • 2
  • 23
  • 42

To display a text banner on all nodes I am using hook_node_view. Then getting the checkbox value from themy custom module settings.yml file.

To display a text banner on all nodes I am using hook_node_view. Then getting the checkbox value from the settings file.

To display a text banner on all nodes I am using hook_node_view. Then getting the checkbox value from my custom module settings.yml file.

added 53 characters in body
Source Link
paul cappucci
  • 1.3k
  • 2
  • 23
  • 42
Loading
added 359 characters in body
Source Link
paul cappucci
  • 1.3k
  • 2
  • 23
  • 42
Loading
Source Link
paul cappucci
  • 1.3k
  • 2
  • 23
  • 42
Loading