/** * Preprocess node template variables. */ function dynamo_preprocess_node(&$variables) { $node = $variables['node']; if (!$variables['page']) { if (isset($variables['field_list_image_rendered']) && strlen($variables['field_list_image_rendered']) > 1) { $variables['list_image'] = $variables['field_list_image_rendered']; } else { $variables['list_image'] = ' '; } } $similar_nodes = similarterms_list(variable_get('ding_similarterms_vocabulary_id', 0)); if (count($similar_nodes)) { $variables['similarterms'] = theme('similarterms', variable_get('similarterms_display_options', 'title_only'), $similar_nodes); } if ($variables['type'] == 'event') { $date = strtotime($node->field_datetime[0]['value']); $date2 = strtotime($node->field_datetime[0]['value2']); // Find out the end time of the event. If there's no specified end // time, we’ll use the start time. If the event is in the past, we // create the alert box. if ($date2 > 0 && $date2 < $_SERVER['REQUEST_TIME']) { $variables['alertbox'] = '<div class="alert">' . t('NB! This event occurred in the past.') . '</div>'; } // More human-friendly date formatting – try only to show the stuff // that’s different when displaying a date range. if (date("Ymd", $date) == date("Ymd", $date2)) { $variables['event_date'] = format_date($date, 'custom', "j. F Y"); } elseif (date("Ym", $date) == date("Ym", $date2)) { $variables['event_date'] = format_date($date, 'custom', "j.") . "–" . format_date($date2, 'custom', "j. F Y"); } else { $variables['event_date'] = format_date($date, 'custom', "j. M.") . " – " . format_date($date2, 'custom', "j. M. Y"); } // Display free if the price is zero. if ($node->field_entry_price[0]['value'] == "0") { $variables['event_price'] = t('free'); } else { $variables['event_price'] = filter_xss($node->field_entry_price[0]['view']); } } }
/** * Preprocess node template variables. */ function dynamo_preprocess_node(&$variables) { $node = $variables['node']; if (!$variables['page']) { if (isset($variables['field_list_image_rendered']) && strlen($variables['field_list_image_rendered']) > 1) { $variables['list_image'] = $variables['field_list_image_rendered']; } else { $variables['list_image'] = ' '; //<--why ?? } } $similar_nodes = similarterms_list(variable_get('ding_similarterms_vocabulary_id', 0)); if (count($similar_nodes)) { $variables['similarterms'] = theme('similarterms', variable_get('similarterms_display_options', 'title_only'), $similar_nodes); } if ($variables['type'] == 'event') { $start = strtotime($node->field_datetime[0]['value'] . 'Z'); $end = strtotime($node->field_datetime[0]['value2'] . 'Z'); // If no end time is set, use the start time for comparison. if (2 > $end) { $end = $start; } // Find out the end time of the event. If there's no specified end // time, we’ll use the start time. If the event is in the past, we // create the alert box. if ($end > 0 && format_date($end, 'custom', 'Ymd') < format_date($_SERVER['REQUEST_TIME'], 'custom', 'Ymd')) { $variables['alertbox'] = '<div class="alert">' . t('NB! This event occurred in the past.') . '</div>'; } // Style date and price $info = theme('event_information', $start, $end); $variables['event_date'] = $info['date']; if ($info['time'] != NULL) { $variables['event_time'] = $info['time']; } $variables['event_price'] = $info['price']; } }
function beats_preprocess_node_celebrity(&$vars) { global $user; $node = node_load(arg(1)); /* * Clelebrity Image */ if(is_array($node->taxonomy)) { foreach($node->taxonomy as $termID => $termData) { if($termData->vid == 1) { $category = $termData->name; } } } $CelebImageUrl = three_beats_celebrity_imagecache('189x245', $node); $vars['celebrity_image'] = "<img src='$CelebImageUrl' class='celeb_img' />"; /** * Chart */ $rating_data = _beats_get_rating_data($node, '2d'); $rating_chart = _beats_get_rating_chart($rating_data); $vars['chart'] = theme('beats_chart_theme', array( 'celebrity_node' => $node, 'rating_data' => $rating_data, 'rating_chart' => $rating_chart, )); /** * RSS Feed */ $url = $node->field_rss[0]['url']; $feeds = array(); if(!empty($url)) { $rss = simplexml_load_file($url); if ($rss->channel->item) { foreach ($rss->channel->item as $item) { $feeds[] = array( 'title' => $item->title, 'link' => $item->link, 'description' => strip_tags($item->description), ); break; } !empty($feeds[0]) ? $vars['feed'] = $feeds[0] : $vars['feed'] = NULL; } } /** * View Celebrity * @todo if anonymous user voting is allowed, than how do we achive it. IP Address? */ $view = views_get_view_result('celebrity', 'block_2', $user->id, arg(1)); if ($user->uid > 0 && is_array($view) && !count($view) > 0) { $vars['form_rating'] = theme('beats_rating_theme', array( 'form' => drupal_get_form('beats_form_rating'), )); } /** * Last User Comments */ if ($user->uid > 0 && is_array($view) && count($view) > 0) { $node = array_shift($view); $node = node_load($node->nid); $vars['form_vote_comment'] = $node->field_vote_comment[0]['value']; } /** * Celebrity User Comments */ $vars['celebrity_comments'] = views_embed_view('celebrity', 'block_3', arg(1)); /** * Celebrity Articles */ $vars['celebrity_articles'] = views_embed_view('article', 'block_2', arg(1)); /** * Similar Celebrities */ $similar_celebrities = array(); $celebrities_node = node_load(arg(1)); if (!empty($celebrities_node->field_related_celebrities) && is_array($celebrities_node->field_related_celebrities)) { foreach ($celebrities_node->field_related_celebrities as $value) { if (!array_key_exists($value['nid'], $similar_celebrities)) { $similar_celebrities[$value['nid']] = node_load($value['nid']); } } } $tmp = similarterms_list(2, arg(1)); if (!empty($tmp) && is_array($tmp)) { foreach ($tmp as $value) { if (!array_key_exists($value->nid, $similar_celebrities)) { $similar_celebrities[$value->nid] = $value; } } } $vars['similar_celebrities'] = $similar_celebrities; }