diff --git a/cms/modules/block_instance/render.html.twig b/cms/modules/block_instance/render.html.twig index 615f0bc9..f6ef2e8e 100644 --- a/cms/modules/block_instance/render.html.twig +++ b/cms/modules/block_instance/render.html.twig @@ -2,6 +2,6 @@ {% if block %} {% if id|default(false) or class|default(false) %}
{% endif %} - {{ sfs_cms_block(block) }} + {{ sfs_cms_block(block, app.request.locale, app.request.attributes.get('_sfs_cms_site')) }} {% if id|default(false) or class|default(false) %}
{% endif %} {% endif %} diff --git a/cms/modules/block_instance_by_type/render.html.twig b/cms/modules/block_instance_by_type/render.html.twig index 1b704ade..5a884d7f 100644 --- a/cms/modules/block_instance_by_type/render.html.twig +++ b/cms/modules/block_instance_by_type/render.html.twig @@ -2,6 +2,6 @@ {% if block %} {% if id|default(false) or class|default(false) %}
{% endif %} - {{ sfs_cms_block_by_type(block) }} + {{ sfs_cms_block_by_type(block, {}, app.request.locale, app.request.attributes.get('_sfs_cms_site')) }} {% if id|default(false) or class|default(false) %}
{% endif %} {% endif %} diff --git a/cms/modules/block_static/render.html.twig b/cms/modules/block_static/render.html.twig index 1b704ade..5a884d7f 100644 --- a/cms/modules/block_static/render.html.twig +++ b/cms/modules/block_static/render.html.twig @@ -2,6 +2,6 @@ {% if block %} {% if id|default(false) or class|default(false) %}
{% endif %} - {{ sfs_cms_block_by_type(block) }} + {{ sfs_cms_block_by_type(block, {}, app.request.locale, app.request.attributes.get('_sfs_cms_site')) }} {% if id|default(false) or class|default(false) %}
{% endif %} {% endif %} diff --git a/src/Render/BlockRenderer.php b/src/Render/BlockRenderer.php index 5c3d21f9..256833e8 100644 --- a/src/Render/BlockRenderer.php +++ b/src/Render/BlockRenderer.php @@ -6,6 +6,7 @@ use Softspring\CmsBundle\Config\CmsConfig; use Softspring\CmsBundle\Config\Exception\InvalidBlockException; use Softspring\CmsBundle\Model\BlockInterface; +use Softspring\CmsBundle\Model\SiteInterface; use Softspring\CmsBundle\Render\Exception\RenderException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -68,7 +69,10 @@ public function renderBlockByType(string $type, array $params = [], ?string $loc } $params['_locale'] = $locale ?? $this->requestStack->getCurrentRequest()?->getLocale(); - $site && $params['_site'] = $site; + + !$site && $site = $this->requestStack->getCurrentRequest()?->attributes->get('_sfs_cms_site', $this->requestStack->getCurrentRequest()?->attributes->get('_site')); + $site && $params['_site'] = $site instanceof SiteInterface ? $site->getId() : $site; + if (!empty($blockConfig['render_url'])) { $params_string = $this->paramsAsString($params); $twigCode = "{{ $renderFunction(url('{$blockConfig['render_url']}', {{$params_string}})) }}";