Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/allowed_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 13 additions & 1 deletion src/Service/QcdThirdPartyBlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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'])) {
Expand Down
4 changes: 4 additions & 0 deletions views/templates/front/_partials/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
/**
* Silence is golden.
*/
31 changes: 31 additions & 0 deletions views/templates/front/_partials/pages-list-items.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{foreach from=$everblock_pages item=page}
<div class="col-md-6 col-lg-4 mb-4">
<article class="card h-100 shadow-sm border-0">
{assign var='coverImage' value=$page->cover_image_data|default:null}
{if $coverImage && $coverImage.url}
<div class="position-relative overflow-hidden rounded-top"
style="aspect-ratio: {$coverImage.width|intval}/{$coverImage.height|intval};">
<img src="{$coverImage.url|escape:'htmlall':'UTF-8'}"
alt="{$coverImage.alt|default:$page->title|default:''|escape:'htmlall':'UTF-8'}"
class="w-100 h-100"
style="object-fit: cover;"
loading="lazy"
width="{$coverImage.width|intval}"
height="{$coverImage.height|intval}" />
</div>
{/if}
<div class="card-body d-flex flex-column">
<h3 class="h5 card-title text-primary">
<a href="{$everblock_page_links[$page->id]|escape:'htmlall':'UTF-8'}" class="stretched-link text-decoration-none">
{$page->title|default:''|escape:'htmlall':'UTF-8'}
</a>
</h3>
{if $page->short_description}
<p class="card-text text-muted">{$page->short_description|strip_tags|truncate:180:'...':true}</p>
{elseif $page->meta_description}
<p class="card-text text-muted">{$page->meta_description|truncate:180:'...':true}</p>
{/if}
</div>
</article>
</div>
{/foreach}
32 changes: 1 addition & 31 deletions views/templates/front/pages-alt.tpl
Original file line number Diff line number Diff line change
@@ -1,37 +1,7 @@
{if $everblock_pages|@count}
<section class="everblock-pages-list everblock-pages-list--builder">
<div class="row">
{foreach from=$everblock_pages item=page}
<div class="col-md-6 col-lg-4 mb-4">
<article class="card h-100 shadow-sm border-0">
{assign var='coverImage' value=$page->cover_image_data|default:null}
{if $coverImage && $coverImage.url}
<div class="position-relative overflow-hidden rounded-top"
style="aspect-ratio: {$coverImage.width|intval}/{$coverImage.height|intval};">
<img src="{$coverImage.url|escape:'htmlall':'UTF-8'}"
alt="{$coverImage.alt|default:$page->title|default:''|escape:'htmlall':'UTF-8'}"
class="w-100 h-100"
style="object-fit: cover;"
loading="lazy"
width="{$coverImage.width|intval}"
height="{$coverImage.height|intval}" />
</div>
{/if}
<div class="card-body d-flex flex-column">
<h3 class="h5 card-title text-primary">
<a href="{$everblock_page_links[$page->id]|escape:'htmlall':'UTF-8'}" class="stretched-link text-decoration-none">
{$page->title|default:''|escape:'htmlall':'UTF-8'}
</a>
</h3>
{if $page->short_description}
<p class="card-text text-muted">{$page->short_description|strip_tags|truncate:180:'...':true}</p>
{elseif $page->meta_description}
<p class="card-text text-muted">{$page->meta_description|truncate:180:'...':true}</p>
{/if}
</div>
</article>
</div>
{/foreach}
{include file='module:everblock/views/templates/front/_partials/pages-list-items.tpl'}
</div>
</section>
{else}
Expand Down
32 changes: 1 addition & 31 deletions views/templates/front/pages.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,7 @@
<section class="everblock-pages-list">
{if $everblock_pages|@count}
<div class="row">
{foreach from=$everblock_pages item=page}
<div class="col-md-6 col-lg-4 mb-4">
<article class="card h-100 shadow-sm border-0">
{assign var='coverImage' value=$page->cover_image_data|default:null}
{if $coverImage && $coverImage.url}
<div class="position-relative overflow-hidden rounded-top"
style="aspect-ratio: {$coverImage.width|intval}/{$coverImage.height|intval};">
<img src="{$coverImage.url|escape:'htmlall':'UTF-8'}"
alt="{$coverImage.alt|default:$page->title|default:''|escape:'htmlall':'UTF-8'}"
class="w-100 h-100"
style="object-fit: cover;"
loading="lazy"
width="{$coverImage.width|intval}"
height="{$coverImage.height|intval}" />
</div>
{/if}
<div class="card-body d-flex flex-column">
<h3 class="h5 card-title text-primary">
<a href="{$everblock_page_links[$page->id]|escape:'htmlall':'UTF-8'}" class="stretched-link text-decoration-none">
{$page->title|default:''|escape:'htmlall':'UTF-8'}
</a>
</h3>
{if $page->short_description}
<p class="card-text text-muted">{$page->short_description|strip_tags|truncate:180:'...':true}</p>
{elseif $page->meta_description}
<p class="card-text text-muted">{$page->meta_description|truncate:180:'...':true}</p>
{/if}
</div>
</article>
</div>
{/foreach}
{include file='module:everblock/views/templates/front/_partials/pages-list-items.tpl'}
</div>

{if isset($everblock_pagination.total_pages) && $everblock_pagination.total_pages > 1}
Expand Down
Loading