Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Assets of toolbar destroys file export #103

Open
Bhoft opened this issue Jan 24, 2014 · 1 comment
Open

Assets of toolbar destroys file export #103

Bhoft opened this issue Jan 24, 2014 · 1 comment

Comments

@Bhoft
Copy link

Bhoft commented Jan 24, 2014

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
Copy link
Author

Bhoft commented Jan 24, 2014

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.

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

No branches or pull requests

1 participant