Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to Show More Smarty Debug Data #3703

Open
bhsmither opened this issue Jan 24, 2025 · 0 comments
Open

Allow to Show More Smarty Debug Data #3703

bhsmither opened this issue Jan 24, 2025 · 0 comments

Comments

@bhsmither
Copy link
Contributor

Smarty does not show as much data when using fetch() as gets shown when using display().

https://smarty-php.github.io/smarty/4.x/designers/chapter-debugging-console/

Note: Using {debug} in a template does produce the same debug data as fetch().

In the controller files, find:

$GLOBALS['smarty']->cache_dir  = CC_SKIN_CACHE_DIR;

Add after:

$GLOBALS['smarty']->debugging_ctrl = (get_ip_address() === "a.b.c.d") ? 'URL' : 'NONE' ; // find your local IP address

This will capture display() into a buffer (display() normally outputs directly), apply the preg_replace(), then die with the buffer contents.

In GUI->display(), from:

die(preg_replace('#</form>#i', '<input type="hidden" name="token" class="cc_session_token" value="'.SESSION_TOKEN.'"></form>', $GLOBALS['smarty']->fetch($file)));

To:

function display_callback($buffer) { return preg_replace('#</form>#i', '<input type="hidden" name="token" class="cc_session_token" value="'.SESSION_TOKEN.'"></form>', $buffer); }
ob_start("display_callback"); $GLOBALS['smarty']->display($file); $display = ob_get_contents(); ob_end_clean();
die($display);

Because Smarty's debugging control could be 'URL', making a page request as follows:

admin.php?SMARTY_DEBUG

will give the debug console with the additional data (that I need - times required to compile, render, and cache the included templates and main template).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant