Prestashop 1.7 在 tpl 文件中包含内联 SVG

Prestashop 1.7 include inline SVG in tpl file

我正在尝试像这样在我的 tpl 文件中包含一个 SVG :

<?php echo file_get_contents("icon.svg"); ?>

你有什么想法吗?

最后,我找到了使用模板系统包含内联 SVG 文件的技巧。

所以我只是在主题的templates文件夹中创建了一个名为_svg的文件夹。我将 icon.svg 文件重命名为 icon.tpl 并使用以下代码包含它:

{include file="_svg/icon.tpl"}

如果你需要一个变量(例如在循环中,使用:

{include file="_svg/icon-{$var.value}.tpl"}

如果您有其他想法,请随时告诉我!

再见!