yii-debug-toolbar icon indicating copy to clipboard operation
yii-debug-toolbar copied to clipboard

Assets of toolbar destroys file export

Open Bhoft opened this issue 11 years ago • 1 comments

Hi i am exporting html to pdf with mpdf and have some difficulties with your debug toolbar.

The problem is, on my development PC i have the toolbar enabled in the config. Now if i export to e.g. pdf i disable all log routes and do my rendering and export to pdf.

foreach (Yii::app()->log->routes as $route) { if ($route instanceof CWebLogRoute) $route->enabled = false; if ($route instanceof YiiDebugToolbarRoute) $route->enabled = false; }

In the generated html code of my views i then still see the import of the js and css files even if the toolbar isn't rendered at all.

And somehow the mPDF has problems with the additional css code :( Therefore i think the code should be extended that the assets are only registered when at least one toobar is "enabled".

e.g. set a variable to true when one toolbar is enabled

private function registerClientScripts() { if($this->owner->enabled) { ... // register css and js files } }

Then the export is working again. I also dont want to request files which arent used at all (e.g. when toolbar is enabled for only a specific ip)

regards Horizons

Bhoft avatar Jan 24 '14 13:01 Bhoft

Hmm seems not to solve my problem :( The problem is that if I disable the toolbar "during" the rendering / controller code the css and js code is already imported because the init of the toolbar already happened.

It would be nice if the files are only imported when the toolbar is displayed (actually printed out) and are not registered when the route is disabled during the code.

Edit found a solution: a simple media setting for the registered css file and my exported pdf is rendered as expected.

$cs->registerCssFile($this->assetsUrl . '/main.css', 'screen, projection');

But maybe you could find a better implementation.

Bhoft avatar Jan 24 '14 14:01 Bhoft