diff --git a/src/EventListener/ParseBackendTemplateListener.php b/src/EventListener/ParseBackendTemplateListener.php
index f2304de..2cc33d7 100644
--- a/src/EventListener/ParseBackendTemplateListener.php
+++ b/src/EventListener/ParseBackendTemplateListener.php
@@ -3,15 +3,16 @@
namespace Magmell\Contao\Inserttags\EventListener;
use Contao\CoreBundle\ServiceAnnotation\Hook;
-use Contao\InsertTags;
use Contao\Input;
use Contao\System;
-use Contao\CoreBundle\InsertTag\InsertTagParser;
+use Contao\Template;
+use Contao\StringUtil;
+use Contao\BackendTemplate;
/**
* @Hook("parseBackendTemplate")
*/
-class ParseBackendTemplateListener
+class ParseBackendTemplateListener extends BackendTemplate
{
public function __invoke(string $buffer, string $template): string
{
@@ -26,9 +27,22 @@ public function __invoke(string $buffer, string $template): string
AND strpos($buffer, '
HTML
') === false
){
$buffer = System::getContainer()->get('contao.insert_tag.parser')->replace($buffer);
+
+ if (!empty($GLOBALS['TL_CSS']) && \is_array($GLOBALS['TL_CSS']))
+ {
+ $strStyleSheets = '';
+
+ foreach (array_unique($GLOBALS['TL_CSS']) as $stylesheet)
+ {
+ $options = StringUtil::resolveFlaggedUrl($stylesheet);
+ $strStyleSheets .= Template::generateStyleTag($this->addStaticUrlTo($stylesheet), $options->media, $options->mtime);
+ }
+
+ $this->stylesheets .= $strStyleSheets;
+ $buffer = str_replace('', '' . $this->stylesheets, $buffer);
+ }
}
}
-
return $buffer;
}
}
diff --git a/src/EventListener/ParseFrontendTemplateListener.php b/src/EventListener/ParseFrontendTemplateListener.php
index 1b0be05..8bbb944 100644
--- a/src/EventListener/ParseFrontendTemplateListener.php
+++ b/src/EventListener/ParseFrontendTemplateListener.php
@@ -5,11 +5,9 @@
use Contao\CoreBundle\ServiceAnnotation\Hook;
use Contao\System;
use Contao\FrontendTemplate;
-use Contao\InsertTags;
use Contao\ArticleModel;
use Contao\PageModel;
use Contao\Input;
-use Contao\CoreBundle\InsertTag\InsertTagParser;
/**
* @Hook("parseFrontendTemplate")
@@ -23,7 +21,6 @@ public function __invoke(string $buffer, string $templateName, FrontendTemplate
if (!isset($GLOBALS['objPage']) || !$GLOBALS['objPage']) {
$a = ArticleModel::findById(Input::get("id"));
$b = PageModel::findByPk($a->pid);
-
if($b->trail) {
$GLOBALS['objPage'] = PageModel::findByPk($b->trail[0]);
}
diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php
index 0d9f3f2..4d29e24 100644
--- a/src/Resources/contao/config/config.php
+++ b/src/Resources/contao/config/config.php
@@ -11,4 +11,4 @@
use Magmell\Contao\Inserttags\EventListener\ParseTemplateListener;
$GLOBALS['TL_HOOKS']['parseBackendTemplate'][] = [ParseBackendTemplateListener::class, '__invoke'];
-$GLOBALS['TL_HOOKS']['parseTemplate'][] = [ParseTemplateListener::class, '__invoke'];
+//$GLOBALS['TL_HOOKS']['parseTemplate'][] = [ParseTemplateListener::class, '__invoke'];
\ No newline at end of file