php – joomla 1.7访问:受保护的菜单参数
作者:互联网
我想访问joomla 1.7中菜单的menu_image参数
Normally I just use:
$currentMenuItem = JSite::getMenu()->getActive();
它给了我所有参数如下,但是params对象中的数据是:protected所以我无法访问$currentMenuItem-> params-> data:protected-> menu_image因为我无法使用:在一个对象中.
Any1知道怎么做呢?
[params] => JRegistry Object
(
[data:protected] => stdClass Object
(
[show_title] =>
[link_titles] =>
[show_intro] =>
[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_icons] =>
[show_print_icon] =>
[show_email_icon] =>
[show_hits] =>
[show_noauth] =>
[menu-anchor_title] =>
[menu-anchor_css] =>
[menu_image] => images/joomla_black.gif
[menu_text] => 1
[page_title] =>
[show_page_heading] => 0
[page_heading] =>
[pageclass_sfx] =>
[menu-meta_description] =>
[menu-meta_keywords] =>
[robots] =>
[secure] => 0
)
)
解决方法:
正如@tereško指出的那样:你扩展了类并创建了一个getter.好吧obv joomla allready有一个getter:所以这里去(例如获取受保护的menu_image)
$currentMenuItem = JSite::getMenu()->getActive();
$currentMenuItem->params->get('menu_image', 'images/no-image.jpg');
标签:php,oop,joomla,joomla1-7 来源: https://codeday.me/bug/20190518/1126596.html