4

Within the config folder there is a general.php file with various vars which are site specific.

how do i get at these from within a plugin?

Thanks for your help.

1
  • its ok i found it - craft()->config->get('JsPath'); for example. Sep 24, 2015 at 10:26

3 Answers 3

7
craft()->config->get('JsPath');
7

For Craft 3:

Craft::$app->config->general->{var name}

4

It is considered best practice to use the public get methods, so while the Craft 3 answer is correct, you should try to get in the habit of calling the methods.

Craft::$app->getConfig()->getGeneral()->varName

It looks more verbose, but generally best practice and follows the coding guidelines.

https://craftcms.com/docs/3.x/extend/coding-guidelines.html#app-component-getters

Your Answer

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

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