Matt Fletcher
Matt Fletcher

Reputation: 9240

Calling the $site_name variable from a module in Drupal 7

I'm creating a custom module that has uses the form API and sends an email on submission- however, I want to make the 'from' email name to be the site name (eg, <My Drupal Site> [email protected]). In phptemplate you can use $site_name, but that doesn't work from a module it seems. I've tried calling &$variables or &$variable or &$vars in the function argument and DSMed it but still nothing. Any ideas?

Many thanks! Matt

Upvotes: 6

Views: 10798

Answers (3)

Alex.Barylski
Alex.Barylski

Reputation: 2933

Done...I dug through the set and get code and none of it ever is sanitized...sanitizing serialized objects would probably break stuff so it makes sense

Upvotes: 0

jamix
jamix

Reputation: 5628

I'd suggest the approach used in core:

variable_get('site_name', 'Drupal');

It's good practice to include the default value in variable_get().

Upvotes: 0

Clive
Clive

Reputation: 36955

You can use:

variable_get('site_name');

anywhere in a module or template file :)

Upvotes: 19

Related Questions