2011-12-13 29 views
5

tôi muốn truy cập các thông số menu_image của một menu trong joomla 1,7joomla 1.7 truy cập: Menu bảo vệ params

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

Và nó mang lại cho tôi tất cả các thông số như dưới đây, NHƯNG dữ liệu trong đối tượng params đã được: bảo vệ vì vậy tôi không thể truy cập $ currentMenuItem-> params-> data: protected-> menu_image bởi vì tôi không thể sử dụng: trong một đối tượng.

Any1 biết cách thực hiện việc này thay thế?

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

     ) 

Trả lời

6

Như @ tereško đã chỉ ra: bạn mở rộng lớp và tạo trình khởi động. Vâng obv joomla allready có một getter: do đó, ở đây đi (Lấy ví dụ bảo vệ menu_image)

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

Cảm ơn rất nhiều, tôi đã đấu tranh với điều đó trong 2,5 quá! –

Các vấn đề liên quan