Jump to content

Recommended Posts

Posted

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

Posted

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;

 

  • Like 2
Posted

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"?

Posted

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

Posted
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

 

  • Like 1
Posted

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.

  • Like 2
Posted
2 minutes ago, LostKobrakai said:

Iirc bootstrapping processwire will do the same, but I'm not 100% certain on that. 

It does.

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
  • Recently Browsing   0 members

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