6

I am trying to get the Alias from a given system path node NID (node/nid), inside of a node_insert function in a custom module.

I already tryied:

drupal_get_path_alias('node/866'); // return node/866 in watchdog dblog

and

url('node/866'); // return node/866 in watchdog dblog

and

drupal_lookup_path('alias', 'node/866'); // return NOTHING in watchdog dblog

and

drupal_get_normal_path('node/866'); // return node/866 in watchdog dblog

It should return seo/preparedUrl, but I can´t find a way to do this.

I need this to change a path before the node is saved.

In URL alias (admin/config/search/path) the Alias(seo/preparedUrl) and System (node/866) are there!

THE ANSWER

First of all, Thanks to @arpitr with the help with devel/php path sugestion! Really fast debug this way!

The answer in my case is that is two languages. The path was in language, but my user was in another so, when I use dpm it continues to print the node/nid, but when I changed my user language to be equals to content language it began to work the way I want!

(I can´t answer my own question or vote up nothing here because I am a new user, so I putted here!)

1 Answer 1

4

It looks like you are debugging through watch dog table, you should better use devel module it provides you several debugging options few are

  • dpm() example in your case : dpm(drupal_get_normal_path('node/866'));
  • devel/php path which allows you to test your php codes. example in your case : simply log in as admin visit sitename/devel/php and execute dpm(drupal_get_normal_path('node/866')); and see what it shows

About the problem

  • Make sure node/866 exists
  • If node exists make sure when you are able to access the node-866 by node/866 and alias which you have configured.
  • As as an option you can delete the existing alias and create the same alias again. And check again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.