TIP: Debugging and Profiling

For anyone who wants to optimize their code or see what’s going under the hood.



Turning on debugging and profiling.




  1. Turning on smarty template debugging (Turn off pop-up blocker)



    file: Smarty.class.php

    set:

    ```php var $debugging = true;

    ```


  2. Turning on profiling



    file: config.php

    set:

    ```php define(‘PROFILER’, true);

    define(‘PROFILER_SQL’, true);

    ```

Some data from Smarty template debugging.



Initial load:



index.tpl (2.48889) (total)



Reload:



index.tpl (0.75394) (total)





DETAIL



initial:


index.tpl (2.48889) (total)
main.tpl (2.19856)
blocks/locations/index/top.tpl (0.02841)
addons/banners/blocks/original.tpl
blocks/locations/index/left.tpl (0.72703)




reload:


index.tpl (0.75394) (total)
main.tpl (0.72579)
blocks/locations/index/top.tpl (0.00901)
addons/banners/blocks/original.tpl
blocks/locations/index/left.tpl (0.19945)

[quote name=‘hyteckit’]

Turning on debugging and profiling.




  1. Turning on smarty template debugging (Turn off pop-up blocker)



    file: Smarty.class.php

    set:

    ```php var $debugging = true;

    ```[/QUOTE]



    You can enable the template debugging by checking “Template debugging console” in General settings and then logging into your store using the admin user account.



    Bob

[URL]http://docs.cs-cart.com/common.php?dispatch=docs/view&node_name=debug-console[/URL]

That makes it easier to turn on debugging.



Funny thing, I think is check that checkbox a few weeks ago.



Didn’t see it in the config files, so I just assume I had to modify smarty.class.php. Haha. :smiley:

If you only want smarty debugging console capability to be only viewable by you and not by the public, or whoever is browsing the store while you have your “debugging” checkbox ticked.



This is how I do it.



In the lib/templater/Smarty.class.php file, around line 488, change


var $_smarty_debug_id = 'SMARTY_DEBUG';




to


var $_smarty_debug_id = 'A_SECRET_KEY_ONLY_KNOWN_TO_YOURSELF';


Meaning, replace ‘SMARTY_DEBUG’ with a easy to remember but private key/id.

This will be appended to your URL whenever you want to show the smarty debugging console.



Then replace


var $debugging_ctrl = 'NONE';




with



var $debugging_ctrl = 'URL';




In the future, whenever you want to show the template debugging console for any of your cs-cart page, just append the secret key to your store url.

Eg. [url]http://www.foo.dom/index.php?secreT_keY[/url]

where secreT_keY is set by you as above



You will not need to check/uncheck the “Template debugging console” in General settings.

It will work for your frontend and backend, basically any pages within your cscart store.



Please ensure that the secret key is secure (not the default) and only known by you, and you will be fine.

Not sure why you are going through this hastle. This functionality is built in by default. The console only shows up for the Admin.