vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   template variable print_r/var_dump (https://vborg.vbsupport.ru/showthread.php?t=109662)

johnobandalong 03-06-2006 10:51 PM

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?

merk 03-07-2006 02:13 AM

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.

rossco_2005 03-07-2006 02:28 AM

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.

merk 03-07-2006 02:59 AM

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.

johnobandalong 03-07-2006 04:18 PM

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.

Adrian Schneider 03-07-2006 04:43 PM

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.

merk 03-07-2006 09:06 PM

Didnt know that one, thanks :)

As for a template debug mode, just modify the function temporarily.

Paul M 03-07-2006 09:17 PM

you can also just use print_r($array); exit;

Then the results will be viewable with nothing else clogging the screen.

Adrian Schneider 03-10-2006 02:40 AM

Quote:

Originally Posted by Paul M
you can also just use print_r($array); exit;

Then the results will be viewable with nothing else clogging the screen.

I usually do that, though I created a few simple functions to include when testing something. Basically they include the <pre> tags, and an optional parameter to exit the script.

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
  • Page Generation 0.01071 seconds
  • Memory Usage 1,726KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete