LAPS Posted March 20, 2020 Share Posted March 20, 2020 Hi there, I have an array-list of static email addresses that I would like to use throughout all the system e.g. in PW hooks and templates. Is there a system-efficient place where to put its statement e.g. in a file that doesn't load each time a page is requested? Link to comment Share on other sites More sharing options...
Zeka Posted March 20, 2020 Share Posted March 20, 2020 https://processwire.com/api/ref/functions/setting/ 3 Link to comment Share on other sites More sharing options...
LAPS Posted March 20, 2020 Author Share Posted March 20, 2020 @Zeka thanks for pointing me out. In which system-efficient place should the setting() function be stated? Link to comment Share on other sites More sharing options...
Zeka Posted March 20, 2020 Share Posted March 20, 2020 @LAPS You can place it in ready.php or if you are using 'prependTemplateFile' option in config.php you can place it in _init.php or whatever you call it. https://github.com/processwire/processwire/blob/master/site-beginner/config.php#L40 1 Link to comment Share on other sites More sharing options...
LAPS Posted March 20, 2020 Author Share Posted March 20, 2020 @Zeka Files such as ready.php and _init.php do load each time a page is requested. Since settings would not change over time I'm looking for a system-efficient place where to state those settings. Link to comment Share on other sites More sharing options...
Zeka Posted March 20, 2020 Share Posted March 20, 2020 You can read more about these two options here https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/ You can use config.php if you preffer (API is not ready), but I would go with ready.php and setting(). 1 Link to comment Share on other sites More sharing options...
dragan Posted March 20, 2020 Share Posted March 20, 2020 You can also create your own .ini file and place it wherever you like: https://www.php.net/manual/en/function.parse-ini-file.php Or a static file you only require/include when needed, from inside your templates. 1 Link to comment Share on other sites More sharing options...
bernhard Posted March 21, 2020 Share Posted March 21, 2020 17 hours ago, Zeka said: You can use config.php if you preffer (API is not ready), but I would go with ready.php and setting(). I think @LAPS wants some place that does NOT load on every request. But all of your mentioned options do load on every request ? How large is that list of E-Mails? ? If that is really too much for every request you can put it In some file that you only include() when you need it In a non-autoload module, that you request when needed (eg $modules->get('myemails')->getAll()) In a WireCache object that is stored in the Database In a dedicated page + field (eg $pages->get(1234)->emailslist) 5 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now