OpenBayou Posted January 7, 2017 Share Posted January 7, 2017 Hey, I'm trying to find a way to see what variables are available using 'print_r' but I get a blank page. This is the code I'm using so far: <?php foreach($pages->find("parent=recommendations") as $child) { ?> <?php echo $child->title;?> <img src="<?php echo $child->post_image->first()->size(200,0)->url;?>"> <?php } ?> I just want to see what's available in $child. When I try to do 'print_r($child)`, I get a blank page. Like a white screen of death. This is what I have so far: <?php foreach($pages->find("parent=recommendations") as $child) { ?> <?php echo $child->title;?> <img src="<?php echo $child->post_image->first()->size(200,0)->url;?>"> <pre> <?php print_r ($child);?> </pre> <?php } ?> Thanks for the help. Link to comment Share on other sites More sharing options...
adrian Posted January 7, 2017 Share Posted January 7, 2017 Tracy to the rescue: <?php foreach($pages->find("parent=recommendations") as $child) { ?> <?php echo $child->title;?> <img src="<?php echo $child->post_image->first()->size(200,0)->url;?>"> <?bd($child);?> <?php } ?> But that said, I really don't know what you mean by: "see what variables are available". If we knew more we could tweak what the bd() call will dump. Are you wanting to get a list of fields on the child pages? Do you mean actual template variables defined for each page? I really don't know. Also, I know you might be used to that style of going in and out of PHP, but when there is more php than html, this reads much nicer: <?php foreach($pages->find("parent=recommendations") as $child) { echo $child->title; echo '<img src="'.$child->post_image->first()->size(200,0)->url.'" />'; bd($child); } Link to comment Share on other sites More sharing options...
OpenBayou Posted January 7, 2017 Author Share Posted January 7, 2017 Quote Are you wanting to get a list of fields on the child pages? Do you mean actual template variables defined for each page? I really don't know. Yes on both. I'm new at ProcessWire and I'm just looking to see what's available. Link to comment Share on other sites More sharing options...
adrian Posted January 7, 2017 Share Posted January 7, 2017 2 minutes ago, OpenBayou said: Yes on both. I'm new at ProcessWire and I'm just looking to see what's available. Check out the PW Info and Template Resources panels in Tracy. Those will show all sorts of info on the contents of fields (and their settings) as well as the variables you have defined manually in your templates. 1 Link to comment Share on other sites More sharing options...
OpenBayou Posted January 7, 2017 Author Share Posted January 7, 2017 How do I access Tracy? Is it a plugin? Link to comment Share on other sites More sharing options...
adrian Posted January 7, 2017 Share Posted January 7, 2017 Just now, OpenBayou said: How do I access Tracy? Is it a plugin? Yes - sorry, I thought I had linked to it earlier: Blog post documentation: http://processwire.com/blog/posts/introducing-tracy-debugger/ Forum thread: https://processwire.com/talk/topic/12208-tracy-debugger/ Modules directory: http://modules.processwire.com/modules/tracy-debugger/ 2 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