I want to insert a css fom the widget block in the magento head but cannot achieve this, i am using:
namespace Vendor\Module\Block\Widget; use Magento\Framework\View\Element\Template; use Magento\Widget\Block\BlockInterface; class Sliderimage extends Template implements BlockInterface { protected function _construct() { parent::_construct(); $this->setTemplate('widget/sliderimage.phtml'); } /** * @return $this */ protected function _prepareLayout() { $this->pageConfig->addPageAsset('Vendor_Module::css/sliderimage.css'); return parent::_prepareLayout(); } }
What am i missing?
Thank you,
Damien.
Hello @KennedyA
protected function _construct() { $om = \Magento\Framework\App\ObjectManager::getInstance(); $page = $om->get('Magento\Framework\View\Page\Config'); $page->addPageAsset('Vendor_Extension::css/yourstyles.css'); }
please check above code
Hope it will help you
Hi @KennedyA
Kindly refer below url :
https://webkul.com/blog/magento2-how-to-add-css-and-js-file-in-module/
It will help you to resolve you issue.
If issue resolve, Please click on 'Kudos' & Accept as Solution!