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 ODDCODE
      Hi, 
      I am sure this question may been asked but I couldn’t find it in the forum. I am new to using Processwire CMS/CMF. I read great reviews on CMS blog about Processwire. So I decided to give It a try. I am trying to figure out what is the best way to structure a simple gallery. I will also need to be able to catalog the photos. 
      Thank you, 
    • By RicknRoller
      Hi there!
      I am quite new to processwire and am just finishing my first PW project. I think the whole framework is awesome and could profit a lot from all the tutorials available. One thing that I somehow can't seem to get my head around is working with images and their resizing. I have following scenario:
      A 'gallery-index' page with its 'gallery' children. Those children have an 'images' field where the user uploads his (often too big) images.
      I am working with twig. On the gallery page frontend I have a slider, a displayed collection of all the images and a hidden one where I get the source to the original image in a popup. So in total the images will be outputted 3 times in different sizes.
      First:
      <div id="slick"> {% for img in page.images %} <img src="{{ img.height(400).url }}" alt=""> {% endfor %} </div> Second:
      <div class="gallery"> {% for img in page.images %} <img src="{{ img.width(300).url }}" alt=""> {% endfor %} </div> Third:
      <div class="hidden"> {% for img in page.images %} <a href="{{ img.maxWidth(1024).url }}" data-original="{{ img.url }}"></a> {% endfor %} </div> Now, the loops basically work, and some images are displayed the right way. But not all of there are displayed at all, despite them being there in the DOM. The urls all look right but some will be displayed and some url just go to a small black box image. How comes that PW manages to have different results in displaying the images in different formats?
      URL of gallery: http://2019.hclaupersdorf.ch/fotos/hc-laupersdorf-vs-ruschlikon-chiefs/ (there are more in the DOM than displayed)
      URL of 'not working' image: http://2019.hclaupersdorf.ch/site/assets/files/2361/20180616-rueschlikon-21_42049612175_o.300x0.jpg
      Furthermore, whenever this error occurs (which usually is at every page request on the gallery page), the DOM doesn't fully load. My JS for init the slider or the popup won't be loaded and the page is basically displayed half-loaded.
      Any ideas or suggestions on how to work around it, best practice when handling images & galleries?
      Thanks!
    • By Falk
      Hi!
      After temporarily using Module Image Extra, which I completely removed, I had some troubles with my imagefield (unused table columns).
      So I just imported a previous version of this column via PHPmyAdmin, which worked pretty well.
      Anyways, in Processwire Backend all image tags are gone, although they are OK in the database.
      Other image related things work (thumbnail, title etc are OK).
      Is there any way to recreate all the images or something? Or may this be an cache-related issue?
       
      Thanks in advance 😃
       
    • By Xonox
      Hi,
      There's something happening in ProcessWire that doesn't compute abd it has to do with images.
      Situation:
      On the homepage template there's a repeater that takes two images to build a slider:
      slide_image: A wide image for desktops
      slide_image_mobile: A more "verticalized" image for small screens
      Now I have this code:
      foreach($page->home_slides as $slide) { // Create desktop slide if(isset($slide->slide_image)) { // Create desktop slide $slide_image = $slide->slide_image->size(1170,400); // Create mobile slide if(isset($slide->slide_image_mobile)) { $slide_image_mobile = $slide->slide_image_mobile->size(1048,800); } else { $slide_image_mobile = $slide->slide_image->size(1048,800); } ?> <div class="slide-content"> <a href="<?php echo $slide->link; ?>" class="slide"> <img src="<?php echo $slide_image->url; ?>" class="img-fluid d-none d-md-block" title="<?php echo $slide->slide_title; ?>" alt="<?php echo $slide->slide_title; ?>" /> <img src="<?php echo $slide_image_mobile->url; ?>" class="img-fluid d-block d-md-none" title="<?php echo $slide->slide_title; ?>" alt="<?php echo $slide->slide_title; ?>" /> </a> </div> <?php } } On my dev server, the small image is detected and placed in content, however in my production server this doesn't happen.
      I've double checked fields names and the fields contain images. I've even imported the database into the Dev Server.
      I don't have any clue why it works locally and not in server.
      Can anyone shed som light?
      Thank you!
    • By Peter Knight
      I have 2 repeater types working with the Repeater Matrix.
      To keep things simple, I have
      image gallery a downloads gallery. I can't quite figure out how to echo the contents from within a product_gallery. 
      I can get the code below to display the text 'An image gallery' but not the bunch of images within this.
      I'm not sure though if it's my variable trail or my nested echo statement.
       
      <?php foreach($page->components as $item) { if($item->type == 'product_gallery') { echo " An image gallery..."; foreach($product_gallery->images as $photo) { echo " An image <image src='{$photo->url}'> "; } } else if($item->type == 'downloads') { echo " A download gallery... "; } } ?> Thanks
      P
×
×
  • Create New...