MarcC Posted Tuesday at 06:28 PM Share Posted Tuesday at 06:28 PM Hi all, (Please see edit below) I have some Hanna Code that returns image data like this: (single-image field inside a repeater) echo "<!-- url: " . $pageToUse->graphical_cta->first->image->url . " -->"; echo "<!-- httpUrl: " . $pageToUse->graphical_cta->first->image->httpUrl . " -->"; echo "<!-- httpsUrl: " . $pageToUse->graphical_cta->first->image->httpsUrl . " -->"; echo "<!-- basename: " . $pageToUse->graphical_cta->first->image->basename . " -->"; echo "<!-- debugInfo: " . $pageToUse->graphical_cta->first->image->debugInfo . " -->"; Result: <!-- url: /site/assets/files/14469/ --><!-- httpUrl: --><!-- httpsUrl: --><!-- basename: --><!-- debugInfo: --> However, the field data shows up OK from within a regular template on the website, and the images work just fine when used via website template. (And just in case, I confirmed that the image folder has files inside of it) Other fields in this graphical_cta repeater also work fine, for example title_text returns text OK. Is there something I can do to test the field properties via API inside the Hanna Code, to figure out what's going on? Thanks! EDIT: Works OK if I use $pageToUse->image->first->url ...even though it's configured as a single image field (Automatic). Is this reflecting some API change? I'm confused as to why it's only doing this in Hanna Code... Link to comment Share on other sites More sharing options...
Peter Knight Posted yesterday at 02:30 AM Share Posted yesterday at 02:30 AM In your example code you have the first before the image. Was that the issue. IE needed images->first()->url Link to comment Share on other sites More sharing options...
MarcC Posted 12 hours ago Author Share Posted 12 hours ago 16 hours ago, Peter Knight said: In your example code you have the first before the image. Was that the issue. IE needed images->first()->url Hi Peter, Thanks for your reply. Since there are no required parameters in first(), I used "first" without parens and got the magic-method effect. This works OK. However I'm confused as to why the field must be treated as an array of images, when it's configured as a single-image field. It seems like I shouldn't have to use "first" at all. As far as I know from using the API in the past, that is. That's what's got me a bit confused. 😶 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