Hi,

I created a content type named youtube. A user enters an ID that gets stored in the content type. I need to somehow create
a hook/module that gets called when an administrator publishes content of the youtube type that accesses the youtube API and
adds the ID to the playlist.

I have the youtube API code working. However, I need to figure out how to trigger it when the admin publishes/unpublishes nodes.
How should I go about this? Any help is greatly appreciated.

Thanks

James

Comments

jureb’s picture

I'd use MYSQL CALL


$listlength=  7; // number of posts in the playlist


$result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.type ='youtube' AND n.status = 1 ORDER BY n.created DESC"), 0, $listlength);

  while ($getnode = db_fetch_object($result)) {
	$nid = $getnode->nid;
	$node = node_load(array('nid' =>  $nid));

	$output .= "<a href='LINK BEFORE YOUTUBE ID" . $node->body . "LINK AFTER YOUTUBE ID'>"; // link to youtube
	$output .= $node->title; // name of the youtube post stored in title
	$output .= "</a><br />"; 
  }

print $output;

nevets’s picture

Not sure what your goal is, you could use views to list information about your 'youtube' content type (ie a playlist).

Or if needed you write a module that implements hook_nodeapi() to catch the additions.

jniesen’s picture

I'm going to try and use the node_api hook. I'll post my problem and solution clearly here once I have it solved.