Gideon So Posted October 7, 2016 Share Posted October 7, 2016 Hi, I tried multi-instance and found that I cannot load image from other installation with $image->httpUrl. <?php $site = new ProcessWire('/path/to/the/site/','url.of.the.site'); echo $site->pages->get(pageid)->imagefield->httpUrl; ?> This return nothing. <?php $site = new ProcessWire('/path/to/the/site/','url.of.the.site'); echo $site->pages->get(pageid)->imagefield->url; ?> This only return the page path like site/assets/files/pageid/ I am using PW 3.0.33 Any ideas?? Gideon Link to comment Share on other sites More sharing options...
BitPoet Posted October 7, 2016 Share Posted October 7, 2016 Is imagefield set to return a single image? This looks like you're accessing the data from a Pagefiles object. In that, case, this should work: echo $site->pages->get(pageid)->imagefield->first()->httpUrl; 2 Link to comment Share on other sites More sharing options...
Gideon So Posted October 7, 2016 Author Share Posted October 7, 2016 Hi BitPoet, Yes. The limit to this field is 1. So I think my syntax is right. Gideon Link to comment Share on other sites More sharing options...
BitPoet Posted October 7, 2016 Share Posted October 7, 2016 Are you passing the full URL to the constructor, i.e. something like "http://yourhost/yourpath/"? If yes, is the formatted value of the field still set to "Automatic"? Link to comment Share on other sites More sharing options...
Gideon So Posted October 7, 2016 Author Share Posted October 7, 2016 Hi, Yes. You can see it $site = new ProcessWire('/path/to/the/site/','url.of.the.site'); I tried to set the field both automatic and one. By the way $site->pages->get(pageid)->httpUrl works. Gideon Link to comment Share on other sites More sharing options...
Gideon So Posted October 11, 2016 Author Share Posted October 11, 2016 On 7/10/2016 at 0:34 PM, BitPoet said: Is imagefield set to return a single image? This looks like you're accessing the data from a Pagefiles object. In that, case, this should work: echo $site->pages->get(pageid)->imagefield->first()->httpUrl; Hi Bitpoet, Eventually you are right. In multi-instance environment, you need to call the first object even the limit of the image filed is set to 1. Maybe this is a bug in multi-instance support. Gideon 1 Link to comment Share on other sites More sharing options...
LostKobrakai Posted October 11, 2016 Share Posted October 11, 2016 I think this might not be a bug, but even intended. It seems pages are returned without output formatting being enabled, which results in the behaviour you're seeing. Iirc bootstrapping processwire will do the same, but I'm not 100% certain on that. If you want your field settings to be respected call ->setOutputFormatting(true) on the page obj. 2 Link to comment Share on other sites More sharing options...
BitPoet Posted October 11, 2016 Share Posted October 11, 2016 2 minutes ago, LostKobrakai said: Iirc bootstrapping processwire will do the same, but I'm not 100% certain on that. It does. Link to comment Share on other sites More sharing options...
Gideon So Posted October 11, 2016 Author Share Posted October 11, 2016 Hi LostKobrakai, It works as expected. Hope this thread help someone in the future. Big thanks to you two. Gideon 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