Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
marble CreditAttribution: marble commentedApplied, thankyou!