Jump to content

Debugging images


microcipcip
 Share

Recommended Posts

Does anybody know why I am unable to debug images? I only see the field name, but not the array with the list of images, I tried xdebug and tracy debugger...

This is my code: var_dumb($page->fields) or dumbAll($page->fields).
This is what I see, note that I have several images (array) in this page:

img_004.jpg


If I try foreach on the fieldgroup and output the fieldname I can get the image url...

P.S. a little bit off topic...but is there a way to just get the data/values of the fields? I don't really care about all the other fields like hooks, wire, notices, etc etc...

Link to comment
Share on other sites

My setup is a little bit confusing, in the "Field List & Values" of ProcessWire popup, I see the following (only "title" field!):

img_005.jpg

If I try to output da($p->banners->toArray()); I get this list, without the array:
img_010.jpg

If I try foreach ($p->banners as $banner) {da($banner); } I get this (and here the strange thing is that the imgs have no width/height, url, httpurl etc). Do you have any idea of what I am doing wrong?

img_006.jpg

Link to comment
Share on other sites

19 minutes ago, microcipcip said:

My setup is a little bit confusing, in the "Field List & Values" of ProcessWire popup, I see the following (only "title" field!):

Looks like you are viewing this on the backend - you need to view that panel/section when viewing the page on the front-end of the site.

 

19 minutes ago, microcipcip said:

If I try to output da($p->banners->toArray()); I get this list, without the array:

Remember that I said getArray(), not toArray()

  • Like 1
Link to comment
Share on other sites

All right, I am starting to understand. The reason I only see the "title" field is that I am getting the page by ID, so that tab is showing the page I'm in. Sorry about the mistake of toArray instead of getArray, I didn't notice it!

Is it possible to get a nicely formatted array like the one on "Field List & Values" in ProcessWire popup, if I am in another page?
I am basically building a REST Api so I can't access the templates directly (it's a single page app that I access from http://mysite/api/pages/pageID, I am following this tutorial).

I am using $p = $pages->get($pageId); and then with da($p->banners->getArray()); I basically see the third screenshot I've shared above.

Link to comment
Share on other sites

Glad it's making sense for you now.

Interestingly I have been thinking about having Tracy use the page that is being edited (when editing a page in the admin), rather than the page for the edit process, but not sure if it is really a good idea because it would prevent investigating the actual edit process page if you did want to. Typically in the backend when using d() or bd() in the console panel I do what you did and define $p to the page I am editing, but of course this doesn't help for the info displayed in the PW Info panel.

I have made a quick modification to the PW Info panel to support my idea of reporting on the page being edited. I have attached the replacement file for the moment. I'd like to hear how you find it. I'll think on it a little more before incorporating in the released version of Tracy.

ProcesswireInfoPanel.inc

 

Link to comment
Share on other sites

Are you talking about the Tracy debugAll() method? When you say it won't show those fields, do you mean the various properties of the images? The output in the PW Info panel is "manually" generated to include all those things. I haven't come across a built in PW method that outputs everything cleanly like that. Take a look at the code I used to generate that array:

https://github.com/adrianbj/TracyDebugger/blob/ac3ff2f6cdfcb151d53f7938d3f4ec270f23b115/ProcesswireInfoPanel.inc#L313-L367

  • Like 2
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...