Closed (fixed)
Project:
Computed Field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Dec 2010 at 18:14 UTC
Updated:
14 Feb 2012 at 17:00 UTC
I recall being able to use $node->title; in the 6.x branch, but it doesn't seem to work using 7.x. Here's the code I'm trying to use:
$player = $node->title;
/* gets the data from a URL */
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$entity_field[0]['value'] = get_data('http://someurl.com/'.$player.'.txt');
Any ideas?
Comments
Comment #1
JHuxley commentedCan you use the nid to get the title? If so this worked for me:
The entity variable is an array with a lot of useful stuff. Can't remember if the title is in there directly, actually.
Comment #2
adrinux commentedJust hit the same issue. I can't see how to examine the content of $entity, so I ended up just doing node_load() after your suggesting of $entity->nid
The rest happens to extract the last word of the title, in my case a surname :)
Comment #3
blasthaus commenteddoesn't $entity->title work?
Comment #4
stephen verdant commentedblasthaus, I think you're right, $entity->title works for me.
Here's two ways to explore $entity:
print '<pre>';print "Entity title is " . $entity->title . "\n";
print_r($entity); // [1] ugly splatter
krumo($entity); // [2] turn devel module on first!
The node_load approach is useful for more complex efforts, like getting the title of a node that this node references.
Comment #5
colan