Ok tut mir Leid für die ganzen Posts aber ich habe jetzt die Lösung dafür:
HTML-Code:
{if {momurl}}
{if $smarty.session.language == german}
<div id="languageflags">
<a class="germanflag" href="{page_url}"><b>DE</b></a>
<a class="italianflag" href="{momurl}"><b>IT</b></a>
</div>
{else}
<div id="languageflags">
<a class="germanflag" href="{momurl}"><b>DE</b></a>
<a class="italianflag" href="{page_url}"><b>IT</b></a>
</div>
{/if}
{else}
<div id="languageflags">
<a class="germanflag" href="{cururl}?language=de"><b>DE</b></a>
<a class="italianflag" href="{cururl}?language=it"><b>IT</b></a>
</div>
{/if}
momurl von oben, cururl das selbe wie beim anderen Thread von mir. Hier nochmal:
PHP-Code:
function smarty_function_cururl($params, &$smarty)
{
$seoBoost = MainFactory::create_object('GMSEOBoost', [], true);
$languageCode = new LanguageCode(new StringType(strtoupper($_SESSION['language_code'])));
$url = '';
$html = '';
$robots = 'index,follow';
$requestUri = gm_get_env_info('REQUEST_URI');
$getParams = parse_url($requestUri, PHP_URL_QUERY);
parse_str($getParams, $getArray);
$getArray = array_keys($getArray);
$languageProvider = MainFactory::create('LanguageProvider', StaticGXCoreLoader::getDatabaseQueryBuilder());
$activeCodes = $languageProvider->getActiveCodes();
if(isset($GLOBALS['actual_products_id']) && !empty($GLOBALS['actual_products_id']))
{
/** @var ProductReadService $productReadService */
$productReadService = StaticGXCoreLoader::getService('ProductRead');
$product = $productReadService->getProductById(new IdType((int)$GLOBALS['actual_products_id']));
if($seoBoost->boost_products)
{
$url = xtc_href_link($seoBoost->get_boosted_product_url($GLOBALS['actual_products_id']));
}
else
{
try
{
$productLinkParams = xtc_product_link($GLOBALS['actual_products_id'], $product->getName($languageCode),
$product->getUrlKeywords($languageCode),
$_SESSION['languages_id']);
}
catch(InvalidArgumentException $e)
{
$productLinkParams = xtc_product_link($GLOBALS['actual_products_id'], '', '',
$_SESSION['languages_id']);
}
$url = xtc_href_link(FILENAME_DEFAULT, $productLinkParams);
}
if($robots === 'index,follow' && $activeCodes->count() > 1)
{
foreach($activeCodes as $code)
{
$langCode = new LanguageCode(new StringType($code->asString()));
$languageId = $languageProvider->getIdByCode($langCode);
if($languageId != $_SESSION['languages_id'])
{
if($seoBoost->boost_products)
{
$altUrl = xtc_href_link($seoBoost->get_boosted_product_url($GLOBALS['actual_products_id'], '',
$languageId));
}
else
{
try
{
$productLinkParams = xtc_product_link($GLOBALS['actual_products_id'],
$product->getName($langCode),
$product->getUrlKeywords($langCode), $languageId);
}
catch(InvalidArgumentException $e)
{
continue;
}
$altUrl = xtc_href_link(FILENAME_DEFAULT, $productLinkParams);
}
if($altUrl !== $url)
{
if($html === '')
{
$html .= htmlspecialchars($url);
}
}
}
}
}
}
elseif(isset($_GET['cat']) && isset($GLOBALS['current_category_id']) && !empty($GLOBALS['current_category_id']))
{
/** @var CategoryReadService $categoryReadService */
$categoryReadService = StaticGXCoreLoader::getService('CategoryRead');
$category = $categoryReadService->getCategoryById(new IdType((int)$GLOBALS['current_category_id']));
if($seoBoost->boost_categories)
{
$url = xtc_href_link($seoBoost->get_boosted_category_url($GLOBALS['current_category_id']));
}
else
{
try
{
$categoryLinkParams = xtc_category_link($GLOBALS['current_category_id'],
$category->getName($languageCode),
$category->getUrlKeywords($languageCode),
$_SESSION['languages_id']);
}
catch(InvalidArgumentException $e)
{
$categoryLinkParams = xtc_category_link($GLOBALS['current_category_id'], '', '',
$_SESSION['languages_id']);
}
$url = xtc_href_link(FILENAME_DEFAULT, $categoryLinkParams);
}
if($robots === 'index,follow' && $activeCodes->count() > 1)
{
foreach($activeCodes as $code)
{
$langCode = new LanguageCode(new StringType($code->asString()));
$languageId = $languageProvider->getIdByCode($langCode);
if($languageId != $_SESSION['languages_id'])
{
if($seoBoost->boost_categories)
{
$altUrl = xtc_href_link($seoBoost->get_boosted_category_url($GLOBALS['current_category_id'],
$languageId));
}
else
{
try
{
$categoryLinkParams = xtc_category_link($GLOBALS['actual_products_id'],
$category->getName($langCode),
$category->getUrlKeywords($langCode), $languageId);
}
catch(InvalidArgumentException $e)
{
continue;
}
$altUrl = xtc_href_link(FILENAME_DEFAULT, $categoryLinkParams);
}
if($altUrl !== $url)
{
if($html === '')
{
$html .= htmlspecialchars($url);
}
}
}
}
}
}
elseif(isset($_GET['coID']) && $activeCodes->count() > 1)
{
$coID = (int)$_GET['coID'];
if($seoBoost->boost_content)
{
$contentId = $seoBoost->get_content_id_by_content_group($coID);
$url = xtc_href_link($seoBoost->get_boosted_content_url($contentId));
}
else
{
$url = xtc_href_link(FILENAME_CONTENT, 'coID=' . $coID);
}
if($robots === 'index,follow' && $activeCodes->count() > 1)
{
foreach($activeCodes as $code)
{
$langCode = new LanguageCode(new StringType($code->asString()));
$languageId = $languageProvider->getIdByCode($langCode);
if($languageId != $_SESSION['languages_id'])
{
if($seoBoost->boost_content)
{
$contentId = $seoBoost->get_content_id_by_content_group($coID, $languageId);
$altUrl = xtc_href_link($seoBoost->get_boosted_content_url($contentId, $languageId));
}
else
{
$altUrl = xtc_href_link(FILENAME_CONTENT, 'coID=' . $coID);
}
if($altUrl !== $url)
{
if($html === '')
{
$html .= htmlspecialchars($url);
}
}
}
}
}
}
//$this->html_output_array['alternateurlcheck'] = $html;
return $html;
}
Edit:
Das einzige Problem hierbei noch ist, SEO. Denn dynamische Parameter hat google nicht gerne.
Aber jene betroffenen Seiten bis auf der Startseite sind für Google sowieso nicht relevant. Somit sollte man am besten die Startseite mit .htaccess umschreiben.