![]() |
template variable print_r/var_dump
Is there a way to dump out all variables that is available at the template level?
If not, is there at least a way to use print_r/var_dump inside a template? |
Yes and No. (use hooks prior to template call or modify fetch_template to instead of echoing out the template, it does a print_r call.)
It would be easier to look at where the template is called from and work out template scope from there. |
Best idea I can come up with is a plugin that sets a variable with your vardump like this:
$var = print_r($var,true); then put $var into your template. |
That wont work. print_r prints directly to stdout.
You would need to use output buffering at the very least, and variable scope could change between the plugin and the template. |
Thanks for the info guys but I was hoping there was a debug mode for the template (ex. smarty's debug mode) that prints out all variables at the template scope.
This way I dont have to know the variable name in order to find what I'm looking for. |
If you want to print_r to a variable, use "print_r($var, true)" the second arguement makes it return instead of echo/print it.
I always just do it in the file I'm working on (which is usually a custom file, not a vB file... even if it is a vB file, just put it back after because that is MUCH easier than working with plugins for debug code). Try using vBulletin's print_r function. I think it is is functions_misc.php (either print_array() or print_ar(). It is a formatted version of print_r. |
Didnt know that one, thanks :)
As for a template debug mode, just modify the function temporarily. |
you can also just use print_r($array); exit;
Then the results will be viewable with nothing else clogging the screen. |
Quote:
Whatever makes debugging faster is good! :) |
All times are GMT. The time now is 01:00 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|