如何在 Prestashop 的头部添加 link 站点地图

How to add link Sitemap in head in Prestashop

在 PrestShop 中,我有 5 种语言,所以我也有 5 个这样的站点地图:

1_de_0_sitemap.xml
1_en_0_sitemap.xml
1_lv_0_sitemap.xml,
etc.

如何将站点地图的 link 添加到当前前端语言的 <head>

这是 PrestaShop 1.5。

正确的方法是在 .tpl 中还是在某些控制器中进行?

您可以在 header.tpl 中完成,但我建议您使用 hookHeader insted。像这样:

public function hookHeader($params)
{
    $sitemap_file = '1_' . $this->context->language->iso_code . '_0_sitemap.xml';
    //could work with echo too
    return 'your link here' . $sitemap_file;
}

祝你好运