What is a custom category?

I wanted to add a tab to the user edit page, i.e. user/%/edit/foo, and used the twitter module as a model. After a significant response and transition using the debugger, I realized that I needed to add a function hook_userin my module, so that part of the %user_categorypath to the menu router would work.

Now it functions as expected, but I really don’t have a clear idea of ​​what I just did and haven’t found a good explanation anywhere.

Can someone explain to me what this means?

+3
source share
3 answers

user_category_loads , , , user/uid/edit/not_a_category, /uid/edit/is _a_category, , , false, bam, wonky menu: '(.

+1

%user_category, , (uid) user_category_load.

. , False FALSE, 404, - , , / URL-.

, , %user , user_load, , , user_category_load.

, user_category_load .

  • , , user/%/edit/foo.
  • .
0

, , user/%/edit, :

<?php
/**
 * Implementation of hook_menu().
 */
function noc_profile_privacy_menu() {
  return array(
    'user/%user_category/edit/privacy' => array(
      'title' => 'Portfolio privacy',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('noc_profile_privacy_form', 1),
      'access callback' => 'content_profile_page_access',
      'access arguments' => array('profile', 1),
      'type' => MENU_LOCAL_TASK,
      'load arguments' => array('%map', '%index'),
    ),
  );
}

/**
 * Implementation of hook_user().
 */
function noc_profile_privacy_user($op, &$edit, &$account, $category = NULL) {
  if ($op === 'categories') {
    return array(array(
      'name' => 'privacy',
      'title' => t('Profile privacy'),
      'weight' => 0,
    ));
  }
}

, 'name' , hook_user(), , user/%user/category/edit hook_menu(). , . , 'load arguments' .

So, I believe that the user category is 'privacy'in my case a bit after editin the path of determining the menu item.

Is this an extra complication? Yes, it seems so.

Edit: I see that my heffice colleague beat me to answer this question. I would not be able to understand all this without the help of Fox, so the crazy props for Fox.

0
source

Source: https://habr.com/ru/post/1734000/


All Articles