Hi, I am wondering how to display the sitename in my module. Any help would be greatly appreciated.

Comments

Biteme’s picture

Like this:

variable_get('site_name', "Default site name")

phai’s picture

Hi,

I'm using Drupal 6.x and I'm searching for the website URL to use in an email notification.

I searched for it in the variables table of my database... I found site_name for the textual name of the website... but if I need the base URL?

Thank you for you help...

PhAI

apaatsio’s picture

Would $_SERVER['SERVER_NAME'] work for you?

phai’s picture

It works, but I prefer to not use server_name on a multidomain website...

However... thank for your suggestion... ;)

scuba_fly’s picture

I know this is an old thread but I think it's better to use $base_url;

Make sure u get it global before using it:

global $base_url;

Freelance Drupal developer, contact me if you want help on your Drupal project.

kpbowler’s picture

Thanks! $base_url was exactly what I needed!

farfanfelipe’s picture

What about if it is a multisite and I need all the list of sites?

N1ghteyes’s picture

Drupal doesn't store information about other sites on the same codebase, but assuming you have the standard structure, you could look at the site names in the sites directory.

i.e.

sites/site1.com
sites/site2.com
sites/dev.site2.com

etc, if you can grab those folder names, should give you the other sites in the install. not really a good idea though, so im open to better suggestions :P.

if i get a chance will post the actual code for doing that in a bit

farfanfelipe’s picture

I am actually working to solve a multisite custom configuration to have the same Drupal core and DB instance for different sites and it is working.

I am not sure if it should be part of the core or just the as a custom module, but I think could be useful for the Drupal community.

http://drupal.org/node/1965620

jaypan’s picture

For Drupal 8:

\Drupal::config('system.site')->get('name')

Contact me to contract me for D7 -> D10/11 migrations.