Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the drupal way to define global constants?

Tags:

drupal

I'm creating a custom "glue" module for my site, and I want to define a path to another site as a global constant. Is there some drupal way to do it beyond putting a define() statement at the top of my module?

like image 517
sprugman Avatar asked Jan 25 '10 23:01

sprugman


2 Answers

Use variable_get and variable_set.

like image 122
Nikit Avatar answered Nov 03 '22 07:11

Nikit


If the glue module is really just for one site and it's no problem if it's hardcoded, by all means hardcode it.

A lot of constants are set in Drupal core's modules: http://api.drupal.org/api/constants/7

If you want a more flexible solution use a table with a single row and put it in there, and expose an interface to the admin to change that the value of that single row.

like image 42
Niels Bom Avatar answered Nov 03 '22 07:11

Niels Bom