这是我的Prestashop 1.7的第一个模板。我使用入门主题。但是现在我遇到了问题,因为我想创建新块。
addresses.tpl
{extends file='page.tpl'}
{block name='page_content_container'}
<div class="container">
<div class="account">
<h2 class="heading">
{block name='page_title'}
{l s='Your addresses' d='Shop.Theme.Customeraccount'}
{/block}
</h2>
<div class="box">
<section id="content" class="page-content page-addresses">
{foreach $customer.addresses as $address}
{block name='customer_address'}
{include file='customer/_partials/block-address.tpl' address=$address}
{/block}
{/foreach}
<footer>
<a href="{$urls.pages.address}" data-link-action="add-address">
{l s='Create new address' d='Shop.Theme.Actions'}
</a>
</footer>
</section>
</div>
</div>
</div>
{/block}
和page.tpl
{extends file='page.tpl'}
{block name='my_account_links'}
{include file='customer/_partials/my-account-links.tpl'}
{/block}
此文件扩展了另一个page.tpl,但没有my_account_links块。问题是。为什么我在addresss.tpl中看不到my_account_links块。当我显示页面时。
亲切的问候
答案 0 :(得分:0)
在addresss.tpl中看不到my_account_links块,因为在addresss.tpl中没有任何{block name='my_account_links'}
。
如果要在addresss.tpl中显示page.tpl,则必须在父文件中“调用”该块并将其扩展到子文件(page.tpl)中。像这样:
Addresses.tpl
{block name='my_account_links'} <!-- YOUR my_account_links OF YOUR PAGE.TPL WILL BE HERE {/block}
{block name='page_content_container'}
<div class="container">
<div class="account">
<h2 class="heading">
{block name='page_title'}
{l s='Your addresses' d='Shop.Theme.Customeraccount'}
{/block}
</h2>
<div class="box">
<section id="content" class="page-content page-addresses">
{foreach $customer.addresses as $address}
{block name='customer_address'}
{include file='customer/_partials/block-address.tpl' address=$address}
{/block}
{/foreach}
<footer>
<a href="{$urls.pages.address}" data-link-action="add-address">
{l s='Create new address' d='Shop.Theme.Actions'}
</a>
</footer>
</section>
</div>
</div>
</div>
{/block}
在您的page.tpl中:
{extends file='addresses.tpl'}
{block name='my_account_links'}
{include file='customer/_partials/my-account-links.tpl'}
{/block}
现在,使用此方法,您的page.tpl(块“ my_account_links”)将显示在您的地址中。tpl