【问题标题】:Is there way to use Drupal menu's "page arguments" in the "access callback" function?有没有办法在“访问回调”函数中使用 Drupal 菜单的“页面参数”?
【发布时间】:2014-08-08 14:29:06
【问题描述】:

有没有办法在“访问回调”函数中使用 Drupal 菜单的“页面参数”? 我需要同时使用“访问参数”和“访问回调”

'页面参数' => array(3, 4),

'访问参数' => 数组('访问我的模块数据'),

'访问回调' => 'mymodule_application_page_access',

是否可以在我的“访问回调”方法 - mymodule_application_page_access 中使用作为“页面参数”传递的值?

【问题讨论】:

    标签: drupal drupal-7 drupal-routes


    【解决方案1】:

    当然可以:

        $menu['mymodule/path1/path2/%/%'] = array(
             //.... some stuff
            'page callback' => 'mymodule_somecallback',
            'page arguments' => array(3, 4),
            'access arguments' => array('access mymodule data',3,4),
            'access callback' => 'mymodule_application_page_access',
            //.... some more stuff
       );
    

    【讨论】:

    • 感谢 skarist!我之前尝试过,但出现错误,然后我意识到我在访问回调方法中只考虑了 2 个参数而不是 3 个!我的错误:)
    猜你喜欢
    • 2015-10-22
    • 1970-01-01
    • 1970-01-01
    • 2022-11-03
    • 2012-03-01
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-10
    相关资源
    最近更新 更多