<script>
if (siteName.indexOf("domain1") != -1)
{document.write("include('domains/domain1/includes/header.html')" )}
else if (siteName.indexOf("domain2") != -1)
{document.write("include('domains/domain2/includes/header.html')")}
else if (siteName.indexOf("domain3") != -1)
{document.write("include('domains/domain3/includes/header.html')")}
else if (siteName.indexOf("domain4") != -1)
{document.write("include('domains/domain4/includes/header.html')")}
</script>
上面仅加载所有域的domain1标头。 仅使用树枝:
{% if 'domain1' in url %}
{{ include('domains/domain1/includes/header.html') }}
{% endif %}
和
{% if url == "https://domain.africa" %}
{% include('domain/location/includes/site.header.html') %}
{% endif %}
确保您的php脚本将
url
变量传递给twig模板。
$url = $_SERVER['HTTP_HOST'];
echo $twig->render('index.html.twig', ['url' => $url]);
url
变量。
{% if 'domain1' in url %}
{{ include('domains/domain1/includes/header.html') }}
{% endif %}