hi,
i don't speak much english, so i paste the new code for you.
function ninesixtyrobots_preprocess_page(&$vars) {
$use_twitter = theme_get_setting('use_twitter');
if (is_null($use_twitter)) {
$use_twitter = 1;
}
$query = theme_get_setting('twitter_search_term');
if (is_null($query)) {
$query = 'lullabot';
}
$query = urlencode($query);
if ($use_twitter) {
$response = drupal_http_request('http://search.twitter.com/search.json?q=' . $query);
$data = json_decode($response->data);
if (is_array($data->results)) {
$tweet = $data->results[array_rand($data->results)];
$vars['site_slogan'] = check_plain($tweet->text);
}
}
}
Comment | File | Size | Author |
---|---|---|---|
#2 | ninesixty_robots_twitter_fail.patch | 1.17 KB | quicksketch |
Comments
Comment #1
qbanguy CreditAttribution: qbanguy commentedHi, this is a very nice theme. However, I was having a hard time getting it to work. When I enable the theme it just showed me a blank page. I started commenting code and narrowed it down to this function "ninesixtyrobots_preprocess_page" on the template.php. Now it works. Hope it helps.
Thanks again for there nice and simple template.
Adrian
Comment #2
quicksketchThis problem looks like it can be caused by the Twitter servers not being available, or your local machine is unable to make http requests. In the event that an http error occurred, the returned data would be empty, throwing a PHP warning. On some PHP installations, this could cause the page to halt entirely and show a white screen.
This patch checks the returned data to make sure that it is valid before attempting to pull a tweet. I've committed this change.