Skip to main content
added 1006 characters in body
Source Link
Ram
  • 1.3k
  • 15
  • 37

In hook_node_insert() i have used drupal_goto(), to go to the newly created node with alias name of it, but id doesn't work.

I have already created url alias with patterns for that content type.

$alias = drupal_get_path_alias('node/'.$node->nid);
drupal_goto($alias);

If i give drupal_goto() with nid it works.

drupal_goto('node/'.$node->nid);

What is the issue with respect to alias name not working or how to get alias of newly created node and get it redirected to view page of it with alias name as url.

Any ideas or suggestions? Thanks in advance.

[Updated][Updated code]

This is the code which i am trying

function hook_node_insert($node)
{
    if($node->type == 'product')
    {
      
        $_SESSION['product_node_nid'] = $node->nid;
        $banner = $_SESSION['banner'];
        $theme = $_SESSION['theme'];
        $params = array();
        $params['node'] = $node;
        $site_email = variable_get('site_mail', '');                
        if(($banner || $theme) || ($banner && $theme)) {
            drupal_goto('payment-approval');
        }
        else {
            //$alias = drupal_get_path_alias('node/'.$node->nid);
            module_load_include('inc', 'pathauto'); // include the inc file for Pathauto module
            pathauto_create_alias('node', 'insert', 'node/'.$node->nid, array('node' => $node), $node->type, $language->language); // Language is optional
            $alias = drupal_get_path_alias('node/'.$node->nid);
            //$alias = drupal_get_path_alias('node/'.$node->nid); print_r($alias); exit();
            drupal_goto($alias);
        }
    }
}

In hook_node_insert() i have used drupal_goto(), to go to the newly created node with alias name of it, but id doesn't work.

I have already created url alias with patterns for that content type.

$alias = drupal_get_path_alias('node/'.$node->nid);
drupal_goto($alias);

If i give drupal_goto() with nid it works.

drupal_goto('node/'.$node->nid);

What is the issue with respect to alias name not working or how to get alias of newly created node and get it redirected to view page of it with alias name as url.

Any ideas or suggestions? Thanks in advance.

[Updated]

In hook_node_insert() i have used drupal_goto(), to go to the newly created node with alias name of it, but id doesn't work.

I have already created url alias with patterns for that content type.

$alias = drupal_get_path_alias('node/'.$node->nid);
drupal_goto($alias);

If i give drupal_goto() with nid it works.

drupal_goto('node/'.$node->nid);

What is the issue with respect to alias name not working or how to get alias of newly created node and get it redirected to view page of it with alias name as url.

Any ideas or suggestions? Thanks in advance.

[Updated code]

This is the code which i am trying

function hook_node_insert($node)
{
    if($node->type == 'product')
    {
      
        $_SESSION['product_node_nid'] = $node->nid;
        $banner = $_SESSION['banner'];
        $theme = $_SESSION['theme'];
        $params = array();
        $params['node'] = $node;
        $site_email = variable_get('site_mail', '');                
        if(($banner || $theme) || ($banner && $theme)) {
            drupal_goto('payment-approval');
        }
        else {
            //$alias = drupal_get_path_alias('node/'.$node->nid);
            module_load_include('inc', 'pathauto'); // include the inc file for Pathauto module
            pathauto_create_alias('node', 'insert', 'node/'.$node->nid, array('node' => $node), $node->type, $language->language); // Language is optional
            $alias = drupal_get_path_alias('node/'.$node->nid);
            //$alias = drupal_get_path_alias('node/'.$node->nid); print_r($alias); exit();
            drupal_goto($alias);
        }
    }
}
added 8 characters in body
Source Link
Ram
  • 1.3k
  • 15
  • 37

In hook_node_insert() i have used drupal_goto(), to go to the newly created node with alias name of it, but id doesn't work.

I have already created url alias with patterns for that content type.

$alias = drupal_get_path_alias('node/'.$node->nid);
drupal_goto($alias);

If i give drupal_goto() with nid it works.

drupal_goto('node/'.$node->nid);

What is the issue with respect to alias name not working or how to get alias of newly created node and get it redirected to view page of it with alias name as url.

Any ideas or suggestions? Thanks in advance.

[Updated]

In hook_node_insert() i have used drupal_goto(), to go to the newly created node with alias name of it, but id doesn't work.

I have already created url alias with patterns for that content type.

$alias = drupal_get_path_alias($node->nid);
drupal_goto($alias);

If i give drupal_goto() with nid it works.

drupal_goto('node/'.$node->nid);

What is the issue with respect to alias name not working or how to get alias of newly created node and get it redirected to view page of it with alias name as url.

Any ideas or suggestions? Thanks in advance.

In hook_node_insert() i have used drupal_goto(), to go to the newly created node with alias name of it, but id doesn't work.

I have already created url alias with patterns for that content type.

$alias = drupal_get_path_alias('node/'.$node->nid);
drupal_goto($alias);

If i give drupal_goto() with nid it works.

drupal_goto('node/'.$node->nid);

What is the issue with respect to alias name not working or how to get alias of newly created node and get it redirected to view page of it with alias name as url.

Any ideas or suggestions? Thanks in advance.

[Updated]

Source Link
Ram
  • 1.3k
  • 15
  • 37

In hook_node_insert drupal_goto with alias name not working

In hook_node_insert() i have used drupal_goto(), to go to the newly created node with alias name of it, but id doesn't work.

I have already created url alias with patterns for that content type.

$alias = drupal_get_path_alias($node->nid);
drupal_goto($alias);

If i give drupal_goto() with nid it works.

drupal_goto('node/'.$node->nid);

What is the issue with respect to alias name not working or how to get alias of newly created node and get it redirected to view page of it with alias name as url.

Any ideas or suggestions? Thanks in advance.