1

In some situations, I need the site name of a Drupal 6 site which is given while installation of the site.

How can I achieve it?

1 Answer 1

5

In both Drupal 6 and Drupal 7, you can use variable_get. The CMI initiative will likely deprecate this function in Drupal 8.

$name = variable_get('site_name', '');

Notice the blank '' at the end, which is the "default" value, in case a variable isn't defined.

2
  • In Drupal 6, variable_get() has a required second parameter: $default. If you leave this required parameter off, you may get PHP warnings (depending on the PHP error level configured on your server).
    – smokris
    Commented Feb 26, 2012 at 18:12
  • Good point, added this.
    – Letharion
    Commented Feb 27, 2012 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.