【问题标题】:joomla 1.7 access :protected menu paramsjoomla 1.7 访问:受保护的菜单参数
【发布时间】:2011-12-13 09:31:39
【问题描述】:

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

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

它给了我下面的所有参数,但是 params 对象中的数据已经 :protected 所以我不能访问 $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
                )

        )

【问题讨论】:

    标签: php oop joomla joomla1.7


    【解决方案1】:

    正如@tereško 指出的那样:您扩展了类并创建了一个 getter 。好吧,obv joomla 已经有了一个 getter:所以这里(例如获取受保护的 menu_image)

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

    【讨论】:

    • 非常感谢,我在 2.5 中也一直在努力解决这个问题!
    猜你喜欢
    • 2013-02-05
    • 2011-03-22
    • 2012-01-14
    • 2020-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-26
    • 1970-01-01
    相关资源
    最近更新 更多