Hi everyone,
I just ran into a problem with YAMS in unique multilingual aliases mode, while having alias paths activated and allowing non-unique aliases for separate documents. Everything works, except that documents in third level are viewing 404 error.
http://site.com/company/about.html works fine,
http://site.com/company/about/us.html however doesn’t, UNLESS I change the document alias to the numeric id of the document so it would be linked to as
http://site.com/company/about/24.html.
Since I really have no idea what could possibly cause this behavior I’m desperate for your help.
greetings
hauptbenutzer
EDIT
After some hours of debugging I finally figured out what is causing this issue. In yams.class.inc.php, line 4975 YAMS loops through the rest of the path to see, if the parents’ actual aliases are equal to those submitted in the URI. The problem is the following line:
$parentId = $this->itsDocParentIds[ $docId ];
Here $docId should be the child’s ID of the current parent. But since it isn’t changed into the parent’s id after comparing the aliases, this loop doesn’t work for paths with more than two levels.
This should fix it (starting line 4975):
// changes here...
$childId = $docId;
foreach ( $path as $virtualAliasDecoded )
{
$virtualAlias = $this->UrlDecode( $virtualAliasDecoded );
// $virtualAliasEncoded = $this->UrlEncode( $virtualAliasDecoded );
// This should be the virtual alias of the parent of the previous
// document...
// here...
$parentId = $this->itsDocParentIds[ $childId ];
if ( $parentId == 0 )
{
return NULL;
}
$targetAlias = $this->itsDocAliases[ $langId ][ $parentId ];
if ( $virtualAlias != $targetAlias )
{
$targetAlias = $this->itsMODx->config['friendly_url_prefix']
. $targetAlias
. $this->itsDocSuffixes[ $parentId ];
// . $this->itsMODx->config['friendly_url_suffix'];
if ( $virtualAlias != $targetAlias )
{
// no match
$langId = NULL;
return NULL;
}
}
// And here...
$childId = $parentId;
}