CCK field widget?

drewish - June 12, 2006 - 20:57
Project:Review
Version:HEAD
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

it'd be cool if the review could render a CCK integer field as stars...

#1

drewish - August 29, 2006 - 18:02

here's a code snipit to modify a review node to a cck node, providing that you've defined it with the same fields:

<?php
$node
= node_load(array('nid'=>$nid, 'type'=>'review'));
if (
$node) {
 
$node->type = 'content_review';
 
$node->field_description[0] = array(
   
'value' => $node->body,
   
'format' => $node->format,
  );
 
$node->field_rating[0] = array(
   
'value' => $node->review_rating,
  );
 
node_save($node);
}
?>

#2

drewish - August 29, 2006 - 18:20

little fuller example:

<?php
$result
= db_query("SELECT nid FROM {node} WHERE type = 'review'");
while (
$o = db_fetch_object($result)) {
 
$node = node_load($o->nid);
  if (
$node) {
   
$node->type = 'content_review';
   
$node->field_description[0] = array(
     
'value' => $node->body,
     
'format' => $node->format,
    );
   
$node->field_rating[0] = array(
     
'value' => $node->review_rating,
    );
   
node_save($node);
  }
  print
"$node->title<br>";
}
?>

#3

duke_ - July 16, 2007 - 17:33

This is very interesting, I've been trying to do this with no success. How do i have to use this code?

Thanks.

#4

clarknova - July 17, 2007 - 01:03

Would you give me an idea on how to use this code, please?

#5

drewish - July 27, 2007 - 17:04

that code is something you'd only need to run once. you could install the devel module, enable the php evaluation block, run that type of code (you'll probably need to tweak it depending on where the data is going), and then when you're finished uninstall the devel module.

 
 

Drupal is a registered trademark of Dries Buytaert.