Jim Bailie Posted April 30, 2018 Share Posted April 30, 2018 Hello All We're a month into development of our new PW application and what a breath of fresh air it is. We're planning to roll out 3400+ pages by 6/1. But we have come to the realization that we have to carry some old baggage forward. For the near future I need to pull some data in before I even start loading Processwire in the index.php file. This has to be done at this point due to possibility of 301/302'ing the request. Question: How can I EFFICIENTLY place an array of data, derived before bootstrapping, into the bowels of PW and use it later when needed? Link to comment Share on other sites More sharing options...
dragan Posted April 30, 2018 Share Posted April 30, 2018 I've read your post now 5 times and am still not sure I understand the whole scenario. Do you mean to import data from somewhere and create PW-pages via API? I also don't get the "301/302" problem. And what do you mean with "later when needed"? Link to comment Share on other sites More sharing options...
Jim Bailie Posted April 30, 2018 Author Share Posted April 30, 2018 11 minutes ago, dragan said: I've read your post now 5 times and am still not sure I understand the whole scenario. Yeah, maybe my preamble made the whole thing too nebulous. Sorry. I need to include a php script on PW's index.php prior to PW starting up. That script will run and generate an array of data. If I do not need to redirect based on that data, I would like to include that data for later use in the _init.php file. What is the best way to get this array of data from index.php to _init.php I hope that's a better description of my dilemma. Thanks! Link to comment Share on other sites More sharing options...
dragan Posted April 30, 2018 Share Posted April 30, 2018 10 minutes ago, Jim Bailie said: What is the best way to get this array of data from index.php to _init.php Well, since you prepend _init.php in PW, simply put your logic there. What kind of data is it anyway? Are we talking huge datasets in GB, or something that could be stored in a JSON file anyway? Perhaps you could run a cron job that produces a file which holds your data that needs to be pre-fetched, and do your if/else logic inside _init.php. I wouldn't really mess with the PW index.php. If it's a simple situation where you want to check if a certain page already exists inside PW, or whether you need to redirect users to the old page, then you could write simple .htaccess redirect rules. (migration / transition phase between current active system and new system which is not yet live) 1 Link to comment Share on other sites More sharing options...
Jim Bailie Posted April 30, 2018 Author Share Posted April 30, 2018 28 minutes ago, dragan said: If it's a simple situation where you want to check if a certain page already exists inside PW, or whether you need to redirect users to the old page This is sort of the essence of what I'm dealing with, but there are some legacy routing and session details that need to be dealt with. And I think I have the solution now! A vast majority of the requests will be satisfied by the PW app. Why not just put all this redirect logic into a PW 404 template?? Would you agree? 1 Link to comment Share on other sites More sharing options...
dragan Posted April 30, 2018 Share Posted April 30, 2018 I think so. Or even use a hook. 2 Link to comment Share on other sites More sharing options...
Jim Bailie Posted May 2, 2018 Author Share Posted May 2, 2018 @dragan Thanks for your help! I'll look for a hook and do this as a module then. 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