Links to ingredient nodes never made if recipe is created before ingredient nodes
jbemmel - June 12, 2009 - 16:04
| Project: | Recipe |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
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;
}
}
#1
Applied, thankyou!
#2
Automatically closed -- issue fixed for 2 weeks with no activity.