Jump to content

custom scripts


helmut2509
 Share

Recommended Posts

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

  • Like 4
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...