0

I want to define some constant for my theme like theme path etc. How i can achieve that.

For module we can define like this

define(THEME_PATH, drupal_get_path('theme', 'xyz'));

But it is undefined in theme. Any suggestion would be appreciated.

1 Answer 1

1

In the preprocess function (hook_preprocess_THEME), you can use this:

$variables['theme_path'] = drupal_get_path('theme', 'xyz');

Which you can then use as $theme_path in your template.

1
  • 1
    Or even better, stick it in the global hook_preprocess, not a specific preprocess, and then it's available in every template
    – Clive
    Commented Apr 30, 2017 at 9:27

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.