Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. $url = 'about-us';
  2. $path = drupal_lookup_path('source', $url);
  3.  
  4. if ($path) {
  5. $node = menu_get_object('node', 1, $path);
  6. return $node->nid;
  7. }
  8. else {
  9. //Error handling in case path provided does not exist
  10. }
  11.  
  12. $argument_one = arg(0); // This will store "node" to the variable.
  13. $node_id = arg(1); // This will store 100 to $node_id variable.
  14.  
  15. $URL = $_SERVER['REQUEST_URI'];
  16. OR
  17. $URL = $_GET['q']
  18. // if using this then the full path needs prepending as this only gets node/nid
  19. OR
  20. $URL = current_path(); // same as GET[q] basically
  21.  
  22. // then this passes to that function you wanted
  23. $nid = getNodeId($URL);
  24.  
  25. $nid = end(arg()); // Get the last number from the URL.
  26.  
  27. $url_arr = explode('/', $url);
  28.  
  29. <?php
  30. $nodeid = $node->nid;
  31. ?>
  32.  
  33. <a href="http://www.mysite.com?nodeid="<? php print ($nodeid) ?>">
  34.  
  35. <?php
  36. $nodeid=$_GET["nodeid"];
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement