Jump to content

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...

Share this post


Link to post
Share on other sites

Then again, if you have Tracy, then look at the PW Info panel and the "Field List & Values" section and you'll get a nicely formatted array, like this:

Screen Shot 2016-11-10 at 7.05.56 PM.png

  • Like 3

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

Thanks a lot, this helps a lot as I can now see the fields from the Admin. Is there a reason why debugAll won't show those nicely formatted fields when I debug from the frontend, but the ProcessWire popup will?

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
1 minute ago, adrian said:

The output in the PW Info panel is "manually" generated to include all those things.

All right now I understand :lol:. Thanks a lot for your help!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By toni
      Hi,
      I'm facing a strang problem. In my template I'm setting different sizes for srcset:
      $view->set('images', $page->picture); <img srcset="{$img->size(780,0)->url} 780w, {$img->size(1024,0)->url} 1024w, {$img->size(1440,0)->url} 1440w" src="{$img->url}" class="col__image"> All fine. However, the moment I reorder images in backend the different generated image sizes are broken.
      Does somebody has an idea what could cause it? 
      Version: ProcessWire 3.0.123 
       
      Thanks!
      Toni
    • By nabo
      Hello
      I'm working on a project that use PW as backend CMS. PW serves formatted data of each page but the engine simply generates json from pagearray.
      I would like to set one or more variations on images, so I think it would be useful if there were a field to set possible variations... even with overrides!
    • By PawelGIX
      Can I convert uploaded images to PNG, GIF, BMP -> JPEG?
      Is there any function in the API that I can change the file type?
    • By Robin S
      Repeater Images
      Adds options to modify Repeater fields to make them convenient for "page-per-image" usage. Using a page-per-image approach allows for additional fields to be associated with each image, to record things such as photographer, date, license, links, etc.
      When Repeater Images is enabled for a Repeater field the module changes the appearance of the Repeater inputfield to be similar (but not identical) to an Images field. The collapsed view shows a thumbnail for each Repeater item, and items can be expanded for field editing.
      Screencast

      Installation
      Install the Repeater Images module.
      Setup
      Create an image field to use in the Repeater field. Recommended settings for the image field are "Maximum files allowed" set to 1 and "Formatted value" set to "Single item (null if empty)". Create a Repeater field. Add the image field to the Repeater. If you want additional fields in the Repeater create and add these also. Repeater Images configuration
      Tick the "Activate Repeater Images for this Repeater field" checkbox. In the "Image field within Repeater" dropdown select the single image field. You must save the Repeater field settings to see any newly added Image fields in the dropdown. Adjust the image thumbnail height if you want (unlike the core Images field there is no slider to change thumbnail height within Page Edit). Note: the depth option for Repeater fields is not compatible with the Repeater Images module.
      Image uploads feature
      There is a checkbox to activate image uploads. This feature allows users to quickly and easily add images to the Repeater Images field by uploading them to an adjacent "upload" field.
      To use this feature you must add the image field selected in the Repeater Images config to the template of the page containing the Repeater Images field - immediately above or below the Repeater Images field would be a good position.
      It's recommended to set the label for this field in template context to "Upload images" or similar, and set the visibility of the field to "Closed" so that it takes up less room when it's not being used. Note that when you drag images to a closed Images field it will automatically open. You don't need to worry about the "Maximum files allowed" setting because the Repeater Images module overrides this for the upload field.
      New Repeater items will be created from the images uploaded to the upload field when the page is saved. The user can add descriptions and tags to the images while they are still in the upload field and these will be retained in the Repeater items. Images are automatically deleted from the upload field when the page is saved.
      Tips
      The "Use accordion mode?" option in the Repeater field settings is useful for keeping the inputfield compact, with only one image item open for editing at a time. The "Repeater item labels" setting determines what is shown in the thumbnail overlay on hover. Example for an image field named "image": {image.basename} ({image.width}x{image.height})  
      https://github.com/Toutouwai/RepeaterImages
      https://modules.processwire.com/modules/repeater-images/
    • By Kiwi Chris
      In the RTE, when inserting a link, there are several input fields that can be used to select a page, including a text input field that will auto-complete with pages on the site.
      When inserting an image, there is only an option to navigate the page tree. (equivalent to the second input option 'Select Page...' on the Insert Link screen from the RTE.
      When inserting an image from another page buried somewhere in the page tree, if you know the name of the page, it would often be quicker to use an auto-complete text field than 'Select Page...' option.
      It would be nice if the image insertion dialog offered the same functionality as the link insertion dialog so that when selecting a page it's possible to choose either to navigate the page tree, or have a text auto-complete field.
×
×
  • Create New...