suntrop Posted March 20, 2017 Share Posted March 20, 2017 I included the PW index.php in a script file and need to return a full URL of pages (autocomplete Ajax response) However, the file is located on another host and I get the wrong URL ajax.example.com/public/search_autocomplete.php I am wondering why ->url and ->httpUrl is /public/found/page/ or ajax.example.com/public/found/page/ instead of /found/page/ or example.com/found/page/ … and how to get the proper URL. Do I need to set the $config->httpHost again or something else? <?php namespace ProcessWire; header('Access-Control-Allow-Origin: *'); error_reporting(-1); include '../../../www/index.php'; $q = wire('sanitizer')->selectorValue( wire('input')->get('q') ); $results = wire('pages')->find('title%=' . $q . ', template=basic-page, limit=10'); $array['query'] = $q; foreach ($results as $result) { $array['suggestions'][] = ['value' => $result->title, 'data' => $result->url]; } echo json_encode($array); 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