2011-12-13 43 views
5

我要訪問一個菜單的menu_image參數的Joomla 1.7的Joomla 1.7訪問:受保護的菜單PARAMS

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

,這讓我像下面的所有參數,但在params對象中的數據已經:保護所以我不能訪問$ 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 
       ) 

     ) 

回答

6

正如@tereško指出的那樣:您擴展該類並創建一個getter。那麼obv joomla allready有一個getter:所以在這裏(例如獲取受保護的menu_image)

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

非常感謝,我一直在掙扎着,在2.5中也一樣! –