Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

joomla 1.7 access :protected menu params

I want to access the menu_image parameter of a menu in joomla 1.7

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

And it gives me all parameters like below, BUT the data in the params object has been :protected so I cant access $currentMenuItem->params->data:protected->menu_image because I cant use : in an object.

Any1 knows how to do this instead?

[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
                )

        )
like image 646
Hans Wassink Avatar asked Dec 13 '11 09:12

Hans Wassink


1 Answers

As @tereško pointed out: you extend the class and create a getter . Well obv joomla allready has a getter: so here goes (Get the protected menu_image for example)

$currentMenuItem = JSite::getMenu()->getActive();
$currentMenuItem->params->get('menu_image', 'images/no-image.jpg');
like image 177
Hans Wassink Avatar answered Nov 03 '22 08:11

Hans Wassink