README.txt 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. The Node Reference URL Widget module adds a new widget to the Node Reference
  2. CCK field type. It auto-populates a node reference field with a value from the
  3. URL, and does not allow this value to be changed once set.
  4. Node Reference URL Widget was written by Nate Haug.
  5. This Module Made by Robots: http://www.lullabot.com
  6. Dependencies
  7. ------------
  8. * Node Reference (part of References)
  9. Install
  10. -------
  11. Installing the Node Reference URL Widget is simple:
  12. 1) Copy the nodereference_url folder to the sites/all/modules folder in your
  13. installation.
  14. 2) Enable the module using Administer -> Modules (admin/modules)
  15. 3) Add or edit a Node Reference field from admin/structure/types/manage/[type]/fields.
  16. When configuring the field, use the "Reference from URL" option.
  17. 4) Follow on-screen help text to configure your Node Reference URL Widget.
  18. Advanced: Build your own links
  19. ------------------------------
  20. Normally you can prepopulate a Node Reference URL widget simply by creating a
  21. link with the following structure:
  22. As HTML:
  23. <a href="/node/add/story/10">Add a story</a>
  24. Or in PHP code:
  25. <a href="<?php print url('node/add/story/' . $node->nid); ?>">Add a story</a>
  26. However if using multiple Node Reference fields, you can populate them by
  27. using a query string instead of embedding the IDs directly in the URL. Assuming
  28. you had two fields, named "field_ref_a" and "field_ref_b", the URL to
  29. prepopulate both of them at the same time would look like this:
  30. In HTML:
  31. <a href="/node/add/story?ref_a=10&ref_b=20">Add a story</a>
  32. Or in PHP code:
  33. <a href="<?php print url('node/add/story', array('query' => array('ref_a' => $nid1, 'ref_b' => $nid2))); ?>">Add a story</a>
  34. Advanced: Support for non-standard URLs
  35. ---------------------------------------
  36. By default Node Reference URL Widget will only work with node form paths that
  37. match the standard Drupal install: "node/add/%type", where %type is a node type
  38. like "blog" or "story". If you want to use Node Reference URL Widget on
  39. non-standard URLs, you may do so by informing Node Reference URL Widget of these
  40. special paths.
  41. To do so, add additional paths to your settings.php with the following code:
  42. $conf['nodereference_url_paths'] = array(
  43. 'node/add/%type/%nid',
  44. 'node/%/add/%type/%nid',
  45. );
  46. Only two tokens are supported:
  47. %type: The node type that will be created.
  48. %nid: The node ID that will be referenced.
  49. The % wildcard may be used when including other dynamic IDs.
  50. In the above example, Node Reference URL Widget will work at either
  51. "node/add/story/2" or "node/1/add/story/2", where "2" is the node ID being
  52. referenced. Important to note: The first URL will be used in the links that Node
  53. Reference URL Widget provides. If needing advanced configuration of links, look
  54. into the Custom Links module: http://drupal.org/project/custom_links.
  55. Support
  56. -------
  57. If you experience a problem with this module or have a problem, file a
  58. request or issue in the Node Reference URL Widget queue at
  59. http://drupal.org/project/issues/nodereference_url. DO NOT POST IN THE FORUMS.
  60. Posting in the issue queues is a direct line of communication with the module
  61. authors.