Difference in rendering when visiting node / 1 and software loading

A node loads the user profile (external database + views). All this works when I visit: node / 123 / profile / id / 3. Now I have executed hook_menu () to load any profile page and get nicer URLs.

When I load it for some reason, $ left in page.tpl.php is suddenly empty, and many other variables do not seem to load. I tried many different functions to render and create the correct $ output, but realized that the node_show () function seems to be a select function.

Testing has shown that for some reason, hook_nodeapi()calls are ignored.
My code is:

/**
 * Implementation of hook_menu
 */
function modulename_menu() {
  $items = array();

  $items['my/nice/url/profile'] = array(
    'description' => 'This page holds a view that shows profiles based on the %',
    'page callback' => 'website_profile_load',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK, 
  );

  return $items;
}

/**
 * Menu path wildcard callback
 */
function website_profile_load() {
  $output = node_show(node_load(1221), false, true);
  return $output;
}

So, what is the right way to do this and get a panel (see comment below) for the correct download?

UPDATE:

Views 2 , . , ( , :)

, . node, , - , .

+3
3

, , -, - node Drupal $path ( $_GET['q']), $_GET['q'], , . , Panel Ctools Pages Manager .

, , , $_GET['q'] .

:

/**
 * Implementation of hook_menu
 */
function modulename_menu() {
  $items = array();

  // For department and having nice URL for their profile pages.
  $items['my/nice/url/profile/%'] = array(
    'description' => 'This page holds a view that shows profiles based on the %',
    'page callback' => 'website_profile_load',
    'page arguments' => arg(4),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK, 
  );

  return $items;
}

/**
 * Menu path callback
 */
function website_profile_load($id = NULL) {

  // Rename the query internally since other functions base the design
  // on the way the query is structured and not simply by the node which
  // is currently loading.
  if(!empty($id)) {
    $path = $_GET['q'] = 'node/1221/profile/id/' . $id;
  }

  // Use ctools function to correctly display node view since 
  // this site heavily uses ctools rendering for panels and
  // web parts / web pages.  
  drupal_load('module', 'page_manager');
  ctools_include('node_view', 'page_manager', 'plugins/tasks');

  if(function_exists('page_manager_node_view')) {
    $output = page_manager_node_view(node_load(1221));
  } else {
    // Will display incorrectly but still load the UI 
    $output = node_page_view(node_load(1221));
  }

  return $output;
}

:)

0
/**
 * Menu path wildcard callback
 */
function website_profile_load($uid = null) {
  if (!$uid) {
    global $user; // if no user passed in argument, show current user profile
    $uid = $user->uid;
  }
  $output = drupal_render(content_profile_show_profiles($uid));
}
0

, node_load Drupal path/ node. , , , / .. . , node_load , , Drupal , . node, , . , , /node.

However, I will offer this simple solution, since it seems that you want to get the same page that you get when you go to 'node / 123 / profile / id / 3', but will be accessible through a link that you define . You just need to configure the redirect in hook_menu like this:

$items['my/nice/url/profile'] = array(
'description' => 'This page holds a view that shows profiles based on the %',
'page callback' => 'drupal_goto',
'page arguments' => 'node/123/profile/id/3',
'access callback' => TRUE,
'type' => MENU_CALLBACK);

This, in essence, means that when you go to 'my / nicer / url / profile', it starts: drupal_goto ('node / 123 / profile / id / 3');

0
source

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


All Articles