I am developing a site with contest nodes. Users can enter the contest by creating a different node (audio, video, image, or story) linked to the contest node via node relation.
INSTEAD, I'd like to dynamically provide a link to create one or more of those nodes directly from the contest node. As you can see below, I've started muddling around with php in a side block BUT realize this is inefficient
Can Computed Field help me do this!!!....
when a contest node is created, the user selects "audio, video, story, or image" from a taxonomy I've created. Four computed fields exist "cfaud, cfvid", etc). The fields will see if the appropriate taxonomy term is selected, and if so, will provide a link to create a node of the same type but either tagged with a term = the title of the contest or simply nodereferencing the contest node (I'd prefer the former).
Any help is MUCH MUCH appreciated.
If you help me, I'll put you on my thank you page at the site
Ruben
the code I've started playing with is below, but probably is garbage for computed field.
<?php
// Only show block from types array and nodes array
//$match = FALSE;
// Which node types
$types = array('contest' => 1);
if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
$nid = (int)arg(1);
$node = node_load(array('nid' => $nid));
$type = $node->type;
if (isset($types[$type])) {
// $match = TRUE;
$terms = taxonomy_node_get_terms($nid);
$output = "<ul>";
foreach($terms as $term){
$sql = "SELECT n.title, n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = $term->tid AND n.nid != $nid LIMIT 5";
$result = db_query(db_rewrite_sql($sql));
if (db_num_rows($result)) {
$output .="<li>$term->name</li><ul>";
while ($anode = db_fetch_object($result)) {
$output .= "<li>".l($anode->title, "node/$anode->nid")."</li>";
}
$output.="</ul>";
}
}
}
}
//return $match;
?>
Comments
Comment #1
rubenk commentedI am not using this method anymore. Instead I am using a side block.