helmut2509 Posted February 16, 2014 Share Posted February 16, 2014 I want to implement some custom functions which are not related to the processwire core. Do I have to store the respective scripts in the module folder? What do I have to do to have access to the session variables in custom scripts? Link to comment Share on other sites More sharing options...
Joss Posted February 16, 2014 Share Posted February 16, 2014 What sort of custom functions are you talking about? Link to comment Share on other sites More sharing options...
horst Posted February 16, 2014 Share Posted February 16, 2014 I want to implement some custom functions which are not related to the processwire core. Do I have to store the respective scripts in the module folder? No, in the module folder only modules should be. You can store them outside of PW: webroot |-customscripts |-site |-wire and you can include them with include_once() or require_once() in the site/config.php if you like. This way your functions are available in PW where ever you need them. What do I have to do to have access to the session variables in custom scripts? You can access all of PWs API variables and methods in your custom functions through the wire() function: $pagearray = wire('pages')->find('mySuperDuperSelectorValue'); $homepage = wire('pages')->get(1); $homepage = wire('pages')->get('/'); $session = wire('session'); if( ! isset($session->myCustomArray['myCustomKey']) ) { $session->redirect('/'); } Please refer to the API: http://processwire.com/api/include/ for more info 4 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