diff --git a/config/allowed_files.php b/config/allowed_files.php index b1c2b93..669a6ae 100644 --- a/config/allowed_files.php +++ b/config/allowed_files.php @@ -260,6 +260,9 @@ 'views/templates/front/faqs.tpl', 'views/templates/front/page.tpl', 'views/templates/front/pages.tpl', + 'views/templates/front/pages-alt.tpl', + 'views/templates/front/_partials/index.php', + 'views/templates/front/_partials/pages-list-items.tpl', 'views/templates/front/preview.tpl', 'views/templates/front/success.tpl', 'views/templates/hook/_partials/google_reviews.tpl', diff --git a/src/Service/QcdThirdPartyBlockRenderer.php b/src/Service/QcdThirdPartyBlockRenderer.php index 337a863..c425931 100644 --- a/src/Service/QcdThirdPartyBlockRenderer.php +++ b/src/Service/QcdThirdPartyBlockRenderer.php @@ -138,7 +138,9 @@ public function renderLatestPagesContext(array &$context, string $blockType): bo } $context['owner_module'] = $this->module->name; - $context['template'] = 'views/templates/front/pages-alt.tpl'; + if ($this->shouldUseAlternatePagesTemplate($context)) { + $context['template'] = 'views/templates/front/pages-alt.tpl'; + } $limit = (int) $this->getContextValue($context, [ ['normalized', 'attributes', 'limit'], @@ -182,6 +184,16 @@ public function renderLatestPagesContext(array &$context, string $blockType): bo return true; } + private function shouldUseAlternatePagesTemplate(array $context): bool + { + $templateVariant = (string) $this->getContextValue($context, [ + ['normalized', 'attributes', 'template_variant'], + ['attributes', 'template_variant'], + ], ''); + + return Tools::strtolower(trim($templateVariant)) === 'alt'; + } + private function ensureNormalizedContext(array &$context): void { if (!isset($context['normalized']) || !is_array($context['normalized'])) { diff --git a/views/templates/front/_partials/index.php b/views/templates/front/_partials/index.php new file mode 100644 index 0000000..3c379e1 --- /dev/null +++ b/views/templates/front/_partials/index.php @@ -0,0 +1,4 @@ + +
+ {assign var='coverImage' value=$page->cover_image_data|default:null} + {if $coverImage && $coverImage.url} +
+ {$coverImage.alt|default:$page->title|default:''|escape:'htmlall':'UTF-8'} +
+ {/if} +
+

+ + {$page->title|default:''|escape:'htmlall':'UTF-8'} + +

+ {if $page->short_description} +

{$page->short_description|strip_tags|truncate:180:'...':true}

+ {elseif $page->meta_description} +

{$page->meta_description|truncate:180:'...':true}

+ {/if} +
+
+ +{/foreach} diff --git a/views/templates/front/pages-alt.tpl b/views/templates/front/pages-alt.tpl index 6e4cd4f..755e0b4 100644 --- a/views/templates/front/pages-alt.tpl +++ b/views/templates/front/pages-alt.tpl @@ -1,37 +1,7 @@ {if $everblock_pages|@count}
- {foreach from=$everblock_pages item=page} -
-
- {assign var='coverImage' value=$page->cover_image_data|default:null} - {if $coverImage && $coverImage.url} -
- {$coverImage.alt|default:$page->title|default:''|escape:'htmlall':'UTF-8'} -
- {/if} -
-

- - {$page->title|default:''|escape:'htmlall':'UTF-8'} - -

- {if $page->short_description} -

{$page->short_description|strip_tags|truncate:180:'...':true}

- {elseif $page->meta_description} -

{$page->meta_description|truncate:180:'...':true}

- {/if} -
-
-
- {/foreach} + {include file='module:everblock/views/templates/front/_partials/pages-list-items.tpl'}
{else} diff --git a/views/templates/front/pages.tpl b/views/templates/front/pages.tpl index 0a2dda8..a0f8e91 100644 --- a/views/templates/front/pages.tpl +++ b/views/templates/front/pages.tpl @@ -4,37 +4,7 @@
{if $everblock_pages|@count}
- {foreach from=$everblock_pages item=page} -
-
- {assign var='coverImage' value=$page->cover_image_data|default:null} - {if $coverImage && $coverImage.url} -
- {$coverImage.alt|default:$page->title|default:''|escape:'htmlall':'UTF-8'} -
- {/if} -
-

- - {$page->title|default:''|escape:'htmlall':'UTF-8'} - -

- {if $page->short_description} -

{$page->short_description|strip_tags|truncate:180:'...':true}

- {elseif $page->meta_description} -

{$page->meta_description|truncate:180:'...':true}

- {/if} -
-
-
- {/foreach} + {include file='module:everblock/views/templates/front/_partials/pages-list-items.tpl'}
{if isset($everblock_pagination.total_pages) && $everblock_pagination.total_pages > 1}