Calling $ site_name variable from a module in Drupal 7

I am creating a custom module that uses the form API and sends an email when submitted. However, I want the name "from" to be named with the site name (for example, <My Drupal Site> no -reply@myhttphost.com ). In phptemplate you can use $ site_name, but this does not work with the module. I tried calling the $ variables and the $ am or $ vars variables in the function argument and DSMed, but still nothing. Any ideas?

Many thanks! Matt

+6
source share
3 answers

You can use:

variable_get('site_name'); 

anywhere in a module or template file :)

+17
source

I would suggest the approach used in the kernel:

 variable_get('site_name', 'Drupal'); 

It is good practice to include a default value in variable_get() .

0
source

Done ... I dug up the kit and got the code, and none of this is disinfected ... sanitizing serialized objects will probably break the material, so it makes sense

0
source

Source: https://habr.com/ru/post/900685/


All Articles