I need to be able to attach multiple images to a single node. I will try and write it myself, I just need some help. What I have determined so far:
The table image_attach needs to be changed so that nid is not unique and primary key. In reality, I don't even think you need a primary key. I also would like to somehow be able to rank the image
I was looking at changing:
case 'load':
$iid = db_result(db_query("SELECT iid FROM {image_attach} WHERE nid=%d", $node->nid));
return array('iid' => $iid);
to this:
case 'load':
$attached = array();
$intX = 0;
$iid = db_query("SELECT iid FROM {image_attach} WHERE nid=%d", $node->nid);
while($row = db_fetch_object($iid)){
$attached[] = $row->iid;
//print node_view($node, TRUE);
}
return array('iid' => $attached);
and
case 'insert':
case 'update':
if (isset($node->iid)) {
db_query("DELETE FROM {image_attach} WHERE nid=%d", $node->nid);
if ($node->iid > 0) {
db_query("INSERT INTO {image_attach} (nid, iid) VALUES (%d, %d)", $node->nid, $node->iid);
}
}
break;
to this:
case 'insert':
if (isset($node->iid)) {
if ($node->iid > 0) {
db_query("INSERT INTO {image_attach} (nid, iid) VALUES (%d, %d)", $node->nid, $node->iid);
}
}
break;
case 'update':
if (isset($node->iid)) {
//db_query("DELETE FROM {image_attach} WHERE nid=%d", $node->nid);
if ($node->iid > 0) {
db_query("UPDATE {image_attach} set nid = %d, iid = %d Where nid = %d, $node->nid, $node->iid, $node->nid);
}
}
break;
I cant figure out how to make use of the array of arrays
Comments
Comment #1
joachim commentedDuplicate of the (monsterish) http://drupal.org/node/81102.
If you can help there, please do.
(For arranging the images for one given node, I'd suggest a 'delta' field, btw.)