如何在drupal中仅显示admin的表单

时间:2022-09-12 08:56:28

I create a module in drupal to show record in front end . Now i want to make a form so that admin can insert data . I tried to make a link with _menu() function but it is not working.

我在drupal中创建了一个模块来显示前端的记录。现在我想创建一个表单,以便管理员可以插入数据。我试图与_menu()函数建立链接,但它无法正常工作。

Here is my code

这是我的代码

 function hello_menu(){
    $items = array();
    $items['hellopage'] = array(

        'title'=>'My Hello Page',
        'description'=>'Hello users',
        'page callback'=>'mutual_output',
        'access callback'=>'user_access',
        'access arguments'=>array('access content'),
        'type'=>MENU_NORMAL_ITEM        
    );
    $items['gethello'] = array(
        'page callback'=>'hello_ajaxCallHandler',
        'access callback'=>'user_access',
        'access arguments'=>array('access content'),
        'type'=>MENU_CALLBACK       
    );

    $items['admin/config/people/hello'] = array(
      'title' => 'hello module',
      'description' => 'Configuration for the hello module.',
      'page callback' => 'show_hello_form',
      'page arguments' => array('access content'),
      'access arguments' => array('administer users'),
      'type' => MENU_NORMAL_ITEM,
    );

    Return $items;  
} 

1 个解决方案

#1


Your code seems correct. apart from the 'page arguments' line in the admin/config/people/hello But that shouldn't break anything

你的代码似乎是对的。除了admin / config / people / hello中的'page arguments'行之外,那不应该破坏任何东西

Could you define what you mean with not working? The hook menu array is cached so you'll need to flush the caches every time you change anything.

你可以定义你不工作的意思吗?钩子菜单数组被缓存,因此每次更改任何内容时都需要刷新缓存。

#1


Your code seems correct. apart from the 'page arguments' line in the admin/config/people/hello But that shouldn't break anything

你的代码似乎是对的。除了admin / config / people / hello中的'page arguments'行之外,那不应该破坏任何东西

Could you define what you mean with not working? The hook menu array is cached so you'll need to flush the caches every time you change anything.

你可以定义你不工作的意思吗?钩子菜单数组被缓存,因此每次更改任何内容时都需要刷新缓存。