You are here

node_load_from_title()

Submitted by Peter on Fri, 2012-01-06 22:30

node_load_from_title() is a function for Drupal 7 to replace functionality lost in the changeover from Drupal 6.

Drupal 6 had a lot of functions with optional selection criteria. You could specify the id of the node or item you want or you could provide something else including the title. Drupal 7 replaces the selectivity of the node_load() function with a more complicated selection process. node_load_from_title() gives you a common requirement, the selection of a not by title, as a function.

api.drupal.org/api/drupal/modules--node--node.module/function/node_load/7#comment-19239 is a typical comment about the change.

  1. Down file node_load_from_title.zip.
  2. Expand the file and check all nine lines of the code to make sure I am not trying to destroy your computer.
  3. Copy the node_load_from_title to your /sites/all/modules/ directory.
  4. Switch on module node_load_from_title in /admin/modules/ directory.
  5. Start using node_load_from_title() in your modules.
  6. Remember to add dependencies[] = node_load_from_title to the .info file in your module.

You are free to use this module in any way you like under Drupal so long as you do not charge for the code. Use the GPL 2 licence as supplied with Drupal 7. If Ubuntu Linux had a decent Git user interface application, I would load this code into drupal.org. If Git had any decent user interfaces, including on Windows, I would load this code into Drupal.org.