fix sitemap

parent 9f1d9359
...@@ -10,16 +10,16 @@ ...@@ -10,16 +10,16 @@
echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL; echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
?> ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<?php foreach ($urls as $url): ?> <?php foreach ($urls as $url): ?>
<url> <url>
<loc><?= yii\helpers\Url::to($url['loc'], true) ?></loc> <loc><?= yii\helpers\Url::to($url['loc'], true) ?></loc>
<?php if($langs) : <?php if($langs) :
foreach ($langs as $lang) : ?> foreach ($langs as $lang) : ?>
<xhtml:link rel="alternate" hreflang="<?=$lang->url?>" href="<?= yii\helpers\Url::to('/'.$lang->url.'/'.$url['loc'], true) ?>"/> <xhtml:link rel="alternate" hreflang="<?=$lang->url?>" href="<?= yii\helpers\Url::to('/'.$lang->url.($url['loc']=='/'?'':'/'.$url['loc']), true) ?>"/>
<?php endforeach; <?php endforeach;
endif; ?> endif; ?>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment