Joomla 3에 문제가 있습니다.
사용자 정의 템플릿을 사용하여 메뉴를 만드는 것은 /templates/mytemplate/html/mod_menu/mainmenu.php에 있습니다.
그러나 메뉴의 링크로 이동하면 "active"배열 인덱스는 항상 false입니다.
예를 들어 현재 페이지는 http://localhost/about.html
배열에서 "활성"인덱스가 비어 있습니다.
[1] => stdClass Object
(
[id] => 102
[menutype] => mainmenu
[title] => О проекте
[alias] => about
[note] =>
[route] => about
[link] => index.php?option=com_content&view=article&id=1
[type] => component
[level] => 1
[language] => *
[browserNav] => 0
[access] => 1
[params] => JRegistry Object
(
[data:protected] => stdClass Object
(
[show_title] =>
[link_titles] =>
[show_intro] =>
[info_block_position] =>
[show_category] =>
[link_category] =>
[show_parent_category] =>
[link_parent_category] =>
[show_author] =>
[link_author] =>
[show_create_date] =>
[show_modify_date] =>
[show_publish_date] =>
[show_item_navigation] =>
[show_vote] =>
[show_tags] =>
[show_icons] =>
[show_print_icon] =>
[show_email_icon] =>
[show_hits] =>
[show_noauth] =>
[urls_position] =>
[menu-anchor_title] =>
[menu-anchor_css] =>
[menu_image] =>
[menu_text] => 1
[page_title] =>
[show_page_heading] => 0
[page_heading] =>
[pageclass_sfx] =>
[menu-meta_description] =>
[menu-meta_keywords] =>
[robots] =>
[secure] => 0
)
)
[home] => 0
[img] =>
[template_style_id] => 0
[component_id] => 22
[parent_id] => 1
[component] => com_content
[tree] => Array
(
[0] => 102
)
[query] => Array
(
[option] => com_content
[view] => article
[id] => 1
)
[deeper] =>
[shallower] =>
[level_diff] => 0
[parent] =>
this empty [active] =>
[flink] => /about.html
[anchor_css] =>
[anchor_title] =>
[menu_image] =>
)
기본 mod_menu
파일 의 모양 에서 활성 속성은 항상 false
메뉴를로드하는 도우미 에 의해 설정 되며 대신 자체 검사를 사용하여 활성 상태를 확인합니다. 즉, 기본 mod_menu.php
파일은 다음 값을 설정합니다.
$list = ModMenuHelper::getList($params);
$base = ModMenuHelper::getBase($params);
$active = ModMenuHelper::getActive($params);
$active_id = $active->id;
$path = $base->tree;
따라서 active_id
현재 메뉴 항목의 ID가 포함됩니다. 따라서 현재 메뉴를 원한다면 다음과 같이 확인할 수 있습니다.
foreach ($list as $i => &$item) :
if ($item->id == $active_id) {
// do something with active item
}
....
}
$list
주 파일에 의해 설정되므로 레이아웃 파일에서 액세스 할 수 있습니다.
다음 검사를 통해 동일한 foreach 루프에서 활성 항목 위에있는 상위 항목을 확인할 수도 있습니다.
if (in_array($item->id, $path)) {}
기술적으로는 첫 번째 foreach
루프를 실행하고 원하는 경우로 설정할 $item->active
수 true
있습니다. 그러나 그 시점에서 당신은 아마도 아이템으로 원하는 것을 할 수있을 것입니다!
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다