The module has a feature to create a link to any node with a title matching an ingredient's name. However, when no such node exists, the recipe will never link to it, even when it is created at a later point in time.

To fix this, I have added the following in my code:

/**
 * JvB: added to fix the problem that links to ingredients aren't made
 * when a recipe is created before the ingredients exist as nodes
 *
 * This hooks into generic node creation/update, and checks if the added
 * node fixes any links in existing recipes
 *
 **/
 function recipe_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'insert':
    case 'update':
      // TODO Could filter for only nodes of type 'ingredient'
      db_query("UPDATE {recipe_ingredient} SET link = '%d' WHERE LOWER(name)='%s'", $node->nid, trim(strtolower($node->title)) );
      break;
  }
}

Comments

marble’s picture

Status: Patch (to be ported) » Fixed

Applied, thankyou!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.