In my website i have some pages with jquery lightbox and some pages without lightbox, to load the pacakges i use following in my controller function which seems to work fine.
public function loadJSLightbox2()
{
$this->assets
->collection('lightboxJs')
//->setPrefix($this->config->site->cloud_url)
->addJs('web/dist/lightbox2/dist/js/lightbox.min.js');
$this->assets
->collection('lightboxCss')
//->setPrefix($this->config->site->cloud_url)
->addCss('web/dist/lightbox2/dist/lightbox.min.css');
}
However in my volt main template (master template) i have define the place holders like below,
{{ assets.outputJs('lightboxJs') }}
{{ assets.outputCss('lightboxCss') }}
this works fine as long we this loadJSlightbox2 functions is called when loading the page. In pages where i dont need to load the plugin i get error called as below.
Phalcon\Assets\Exception: The collection does not exist in the manager
How do i archieve this behaviour in my web applicaiton ?