Closed vodanh109 closed 7 years ago
@vodanh109 Are you in developer mode? I recommend it. It makes development a lot easier because connector files like interceptors are generated for you
magento deploy:mode:show
magento deploy:mode:set developer
rm -rf var/generation/* var/di/*
rm -rf generated/code/* generated/metadata/*
If the issue persists, maybe there is a stale module in the vendor directory.
mv vendor vendor.bak
composer install
magento setup:upgrade # why not
Those are general troubleshooting tips just to check that you aren't defeating yourself with one of M2's many caches. If the issue persists, then it is less likely that your environment is wrong, and more likely that you found a defect in the framework.
@nshiff, thanks a lot for your suggestion that help me to easily debug to find out the root cause. The problem is coming from Template Monster theme that have a PHP class to add dynamic css but without 'src' attribute into layout.
@vodanh109 Where exactly did they mess up ? Having the same issue here with Templatemonster theme... Can't the exact error location yet. Or better, how did you fine the faulty TemplateMonster file ?
Can you give us the name of the class in question so we can resolve it :D Thanks in advanced
Sorry for late response. It's app/code/TemplateMonster/ThemeOptions/Observer/AddDynamicStyles.php
@vodanh109 Could you please post what you changed in AddDynamicStyles.php? I am having the exact same issue and TemplateMonster (despite claiming their theme works 100% with 2.2) is giving me the run around.
@vodanh109 I would like to know aswell. I'm also using TemplateMonster.
Edit:
I solved it by modifying the execute() method in AddDynamicStyles.php
:
public function execute(Observer $observer)
{
/** @var \Magento\Framework\View\Layout $layout */
$layout = $observer->getData('layout');
$pageConfig = $layout->getReaderContext()->getPageConfigStructure();
$this->_cssOptions = array_merge(['src' => $this->_getCssUrl()], $this->_cssOptions);
$pageConfig->addAssets($this->_getCssUrl(), $this->_cssOptions);
}
Hello,
Just like to add. In few template monster theme this solution needs to also apply on
app/code/TemplateMonster/NewsletterPopup/Observer/AddDynamicStyles.php
thank you @vodanh109, you saved my ass today!
I have same problem with issue #11224. Please give to me the solution for this. My layout xml definitely have "src" attribute in each css item of "head"
Preconditions
PHP 7.0.22-0ubuntu0.16.04.1
Before: Magento verison 2.1.9 After: Magento version 2.2
Steps to reproduce
Expected result
FrontEnd can work well
Actual result
FrontEnd is crashed