2011-12-13 14 views
5

Chcę uzyskać dostęp do parametru menu_image z menu w Joomla 1,7joomla 1.7 Dostęp: protected menu params

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

I to daje mi wszystkie parametry jak poniżej, ale dane w obiekcie params jest: chroniony więc nie mogę uzyskać dostępu do $ currentMenuItem-> params-> data: protected-> menu_image, ponieważ nie mogę użyć: w obiekcie.

Any1 wie, jak to zrobić?

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

     ) 

Odpowiedz

6

Jak podkreślił @ tereško: rozszerzasz klasę i tworzysz gettera. Cóż, obv joomla ma już gettera: więc tutaj idzie (Get chronione menu_image na przykład)

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

Wielkie dzięki, ja też borykałem się z tym w 2,5! –