Fix sitemaps for multilang
This commit is contained in:
parent
ae595d8545
commit
ecadc03b75
@ -2283,12 +2283,12 @@ if ($action == 'generatesitemaps' && $usercanedit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Forge $pageurl, adding language prefix if it is an alternative language
|
// Forge $pageurl, adding language prefix if it is an alternative language
|
||||||
$pageurl = $objp->pageurl;
|
$pageurl = $objp->pageurl.'.php';
|
||||||
if ($objp->fk_default_home == $objp->rowid) {
|
if ($objp->fk_default_home == $objp->rowid) {
|
||||||
$pageurl = '';
|
$pageurl = '';
|
||||||
} else {
|
} else {
|
||||||
if ($shortlangcode != substr($object->lang, 0, 2)) {
|
if ($shortlangcode != substr($object->lang, 0, 2)) {
|
||||||
$pageurl = $shortlangcode.'/'.$pageurl.'.php';
|
$pageurl = $shortlangcode.'/'.$pageurl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2319,6 +2319,8 @@ if ($action == 'generatesitemaps' && $usercanedit) {
|
|||||||
|
|
||||||
// Now add alternate language entries
|
// Now add alternate language entries
|
||||||
if ($object->isMultiLang()) {
|
if ($object->isMultiLang()) {
|
||||||
|
$alternatefound = 0;
|
||||||
|
|
||||||
// Add page "translation of"
|
// Add page "translation of"
|
||||||
$translationof = $objp->fk_page;
|
$translationof = $objp->fk_page;
|
||||||
if ($translationof) {
|
if ($translationof) {
|
||||||
@ -2336,8 +2338,10 @@ if ($action == 'generatesitemaps' && $usercanedit) {
|
|||||||
$xhtmllink = $domtree->createElement('xhtml:link', '');
|
$xhtmllink = $domtree->createElement('xhtml:link', '');
|
||||||
$xhtmllink->setAttribute("rel", "alternante");
|
$xhtmllink->setAttribute("rel", "alternante");
|
||||||
$xhtmllink->setAttribute("hreflang", $tmpshortlangcode);
|
$xhtmllink->setAttribute("hreflang", $tmpshortlangcode);
|
||||||
$xhtmllink->setAttribute("href", $domainname.'/'.$tmppage->pageurl);
|
$xhtmllink->setAttribute("href", $domainname.($objp->fk_default_home == $tmppage->id ? '/' : (($tmpshortlangcode != substr($objp->lang, 0, 2)) ? '/'.$tmpshortlangcode : '').'/'.$tmppage->pageurl.'.php');
|
||||||
$url->appendChild($xhtmllink);
|
$url->appendChild($xhtmllink);
|
||||||
|
|
||||||
|
$alternatefound++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2355,10 +2359,12 @@ if ($action == 'generatesitemaps' && $usercanedit) {
|
|||||||
}
|
}
|
||||||
if ($tmpshortlangcode != $shortlangcode) {
|
if ($tmpshortlangcode != $shortlangcode) {
|
||||||
$xhtmllink = $domtree->createElement('xhtml:link', '');
|
$xhtmllink = $domtree->createElement('xhtml:link', '');
|
||||||
$xhtmllink->setAttribute("rel", "alternante");
|
$xhtmllink->setAttribute("rel", "alternate");
|
||||||
$xhtmllink->setAttribute("hreflang", $tmpshortlangcode);
|
$xhtmllink->setAttribute("hreflang", $tmpshortlangcode);
|
||||||
$xhtmllink->setAttribute("href", $domainname.'/'.$objhastrans->pageurl);
|
$xhtmllink->setAttribute("href", $domainname.($objp->fk_default_home == $objhastrans->id ? '/' : (($tmpshortlangcode != substr($objp->lang, 0, 2) ? '/'.$tmpshortlangcode : '')).'/'.$objhastrans->pageurl.'.php');
|
||||||
$url->appendChild($xhtmllink);
|
$url->appendChild($xhtmllink);
|
||||||
|
|
||||||
|
$alternatefound++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2366,12 +2372,14 @@ if ($action == 'generatesitemaps' && $usercanedit) {
|
|||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add myself
|
if ($alternatefound) {
|
||||||
$xhtmllink = $domtree->createElement('xhtml:link', '');
|
// Add myself
|
||||||
$xhtmllink->setAttribute("rel", "alternante");
|
$xhtmllink = $domtree->createElement('xhtml:link', '');
|
||||||
$xhtmllink->setAttribute("hreflang", $shortlang);
|
$xhtmllink->setAttribute("rel", "alternate");
|
||||||
$xhtmllink->setAttribute("href", $domainname.'/'.$pageurl);
|
$xhtmllink->setAttribute("hreflang", $shortlangcode);
|
||||||
$url->appendChild($xhtmllink);
|
$xhtmllink->setAttribute("href", $domainname.'/'.$pageurl);
|
||||||
|
$url->appendChild($xhtmllink);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$root->appendChild($url);
|
$root->appendChild($url);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user