joomla 1.7访问:受保护的菜单参数

时间:2011-12-13 09:31:40

标签: php oop joomla joomla1.7

我想访问joomla 1.7中菜单的menu_image参数

Normally I just use:
$currentMenuItem = JSite::getMenu()->getActive();

它给了我所有参数如下,但是params对象中的数据是:protected所以我无法访问$ currentMenuItem-> params-> data:protected-> menu_image因为我无法使用:in a对象

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
                )

        )

1 个答案:

答案 0 :(得分:6)

正如@tereško所指出的:你扩展了类并创建了一个getter。那么obv joomla allready有一个getter:所以这里去(例如获取受保护的menu_image)

$currentMenuItem = JSite::getMenu()->getActive();
$currentMenuItem->params->get('menu_image', 'images/no-image.jpg');