We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Add css to a collection and output it like inline css

I am using asset manager to produce a css collection into the frontend. There are some files which I want to print it inline.

Is there any way to do something like

$this->assets ->collection($inline_name) ->addCss('css/front/_bootstrap.min.css') ->addCss('css/front/site.css') ->join(true) ->setTargetPath('css/front/final'.$inlinename.'.css') ->setTargetUri('css/front/final'.$inline_name.'.css') ->addFilter(new \Phalcon\Assets\Filters\Cssmin());

And in the front-end to get this collection as inline css. I mean that i dont want to use addInlineCss('...') in the controller.

I have no idea what y ou are trying to achive here :) but if the issue is that you don't want to add them to the controller, use partials instead and it where needed.

See: https://docs.phalcon.io/en/latest/reference/views.html#using-partials

Regarads André

edited Jan '16

collections are printed in view using

{{ assets.outputCss(inline_name) }}

in which case you should pass $inline_name variable to the view ($this->view->setVar("inline_name", $inline_name);)

and inline css is printed with

{{ assets.outputInlineCss() }}