Drupal 8 修改sitename

admin 提交于 周二, 01/30/2018 - 11:27

1.代码方法

$config = \Drupal::service('config.factory')->getEditable('example.settings');

// Set and save new message value.
$config->set('message', 'Hi')->save();

// Now will print 'Hi'.
print $config->get('message');

参照以上代码

//$config = \Drupal::config('system.site');
//$config = \Drupal::service('config.factory')->getEditable('system.site');
//$config->set('name','123')->save();
//$userInfo['sitename'] = $config->get('name');

参照地址:https://www.drupal.org/docs/8/creating-custom-modules/defining-and-using-your-own-configuration-in-drupal-8

2.修改settings.php文件

$config['system.site']['name'] = '新网站标题';

 

标签