Zitat von
Spooky
Sollte es nicht eigentlich
PHP-Code:
$url = $this->generateFrontendUrl( $objDetailPage->row() , "/".$id );
sein?
Sorry, das stimmt natürlich.
Ich habe in der Klasse mir die Methode getPageIdFromUrl() angesehen, die ja zum Start von Contao in der index.php aufgerufen wird. Meinem Verständnis werden mit dem beigefügten Coding alle Parameter den $_GET-Parametern zugeordnet. Ist das nicht korrekt?
PHP-Code:
// Use folder-style URLs
if (\Config::get('folderUrl') && strpos($strRequest, '/') !== false)
{
$strAlias = $strRequest;
$arrOptions = array($strAlias);
// Compile all possible aliases by applying dirname() to the request (e.g. news/archive/item, news/archive, news)
while ($strAlias != '/' && strpos($strAlias, '/') !== false)
{
$strAlias = dirname($strAlias);
$arrOptions[] = $strAlias;
}
// Check if there are pages with a matching alias
$objPages = \PageModel::findByAliases($arrOptions);
if ($objPages !== null)
{
$arrPages = array();
// Order by domain and language
while ($objPages->next())
{
$objPage = $objPages->current()->loadDetails();
$domain = $objPage->domain ?: '*';
$arrPages[$domain][$objPage->rootLanguage][] = $objPage;
// Also store the fallback language
if ($objPage->rootIsFallback)
{
$arrPages[$domain]['*'][] = $objPage;
}
}
$strHost = \Environment::get('host');
// Look for a root page whose domain name matches the host name
if (isset($arrPages[$strHost]))
{
$arrLangs = $arrPages[$strHost];
}
else
{
$arrLangs = $arrPages['*']; // Empty domain
}
$arrAliases = array();
// Use the first result (see #4872)
if (!\Config::get('addLanguageToUrl'))
{
$arrAliases = current($arrLangs);
}
// Try to find a page matching the language parameter
elseif (($lang = \Input::get('language')) != '' && isset($arrLangs[$lang]))
{
$arrAliases = $arrLangs[$lang];
}
// Return if there are no matches
if (empty($arrAliases))
{
return false;
}
$objPage = $arrAliases[0];
// The request consists of the alias only
if ($strRequest == $objPage->alias)
{
$arrFragments = array($strRequest);
}
// Remove the alias from the request string, explode it and then re-insert the alias at the beginning
else
{
$arrFragments = explode('/', substr($strRequest, strlen($objPage->alias) + 1));
array_unshift($arrFragments, $objPage->alias);
}
}
Lesezeichen