정식 URL (SEF404 옆)을 제공하는 Joomla 2.5 용 작동 플러그인이 없으므로 템플릿을 "해킹"하고 필요할 때 정식 URL을 포함 시키려고합니다.활성 메뉴 URL 얻기
모든 메뉴 항목에 다른 URL 및 GET-Parameters를 사용하여 액세스 할 수 있으므로 필요한 경우 표준 URL을 포함하고 싶습니다.
가장 쉬운 해결책은 활성 메뉴 항목의 URL을 가져 오는 것인데 액세스 된 URL이 이와 다른 경우 표준 URL 태그 (템플릿의 index.php)에 표준 태그를 포함시키는 것입니다.
기본 PHP 지식을 가지고 있지만 활성 메뉴 항목의 URL과 액세스 한 URL을 얻는 방법을 모르겠습니다. 아무도이 정보를 얻는 방법을 말해 줄 수 있습니까? 이걸 가지고 있다면 간단하게 비교할 수 있고 다른 경우에는 태그를 추가하면됩니다.
이 정보를 얻는 방법에 대한 샘플 코드를 게시하십시오.
편집 : 여기에 몇 가지 기본 정보 ("홈페이지"에만 관련됨)가 있지만이 코드는 작동하지 않습니다. http://writenowdesign.com/joomla-tutorials/joomla-trips-and-tricks/add-canonical-url-link-to-joomla-home-page/
EDIT2 :
<?php
// Source: http://www.php.de/php-einsteiger/91123-erledigt-aktuelle-browser-url-ausgeben-funktion-zweckdienlich-2.html
function getUrl($arrAddParam = false, $xhtmlValid = false, $anchor = false, $dropCalledArgs = false) {
$url = !empty($_SERVER['HTTPS']) ? 'https://' : 'http://';
$url .= $_SERVER['SERVER_NAME'];
$url .= $_SERVER['SCRIPT_NAME'];
// merge input and user param arrays
$arrParam = is_array($arrAddParam) ? $arrAddParam : array();
if ($dropCalledArgs === false) $arrParam = array_merge($_GET,$arrParam);
if (!empty($arrParam)) {
$arg_separator = $xhtmlValid ? '&' : '&';
$url .= "?". http_build_query($arrParam, '', $arg_separator);
}
// anchor
if ($anchor !== false) {
$url .= '#'.$anchor;
}
return $url;
}
// Get the application object
$app = JFactory::getApplication();
// Get's the menu object
$menu = $app->getMenu();
// Current URL
$activeUrl = getUrl();
// SHOULD get the active menu target as string, but it's an object
// THIS is my question how to get the URL of the current active menu item
$menuUrl = $menu->getActive();
?>
편집 : 3 : 예를 들어 Here이 URL을 얻을 수있는 가능성이다. 하지만 나는 "정상적인"이 아닌 SEO URL이 필요합니다.
이것은 JS를 통한 현재 URL입니다. 예 - 조금 더 자세히 설명하기 위해 주요 질문을 다시 편집하겠습니다. – Andy
"Edit 2"를보세요 : – Andy