Hook | Description |
---|---|
compileSlickNewsList | Modify slick news frontend module output. |
compileSlickEventList | Modify slick event frontend module output. |
Event is dispatched before initializing slick instance. Call Event.preventDefault()
to prevent initialization.
Parameters:
- {Element} element: Element container .slick css class
- {Element} slickContainer: Element contains .slick-container css class becoming slick instance
- {object} config: Slick config
Bubbles: true
Cancelable: yes
Interface: CustomEvent
Event is dispatched after initializing slick.
Parameters:
- {jQuery} slickInstance: Element container .slick css class
- {Element} element: Element container .slick css class
- {Element} slickContainer: Element contains .slick-container css class becoming slick instance
Bubbles: true
Cancelable: false
Interface: CustomEvent
If you need to add slick to a custom element, you need to add the slick assets. The easiest way (and it also optional supports encore bundle) is to use the FrontendAsset
service.
use Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use HeimrichHannot\SlickBundle\Asset\FrontendAsset;
class MyFrontendModuleController extends AbstractFrontendModuleController
{
private $frontendAsset;
public function __construct(FrontendAsset $frontendAsset)
{
$this->frontendAsset = $frontendAsset;
}
protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response
{
// Do something...
$this->frontendAsset->addFrontendAssets();
return $template->getResponse();
}
}