function noreg_preprocess_node__sale_ad(&$variables) { // All node types but page if ($variables['elements']['#view_mode'] != 'page') { // Litter if ($field_litter = field_get_items('node', $variables['node'], 'field_litter_id')) { $node_litter = node_load($field_litter[0]['target_id']); // Birthdate if ($field_litter_birthdate = field_get_items('node', $node_litter, 'field_birthdate')) { $variables['litter_birthdate'] = field_view_value('node', $node_litter, 'field_birthdate', $field_litter_birthdate[0], array('settings' => array('format_type' => 'custom_short'))); } // Price per young if ($field_litter_price_per_young = field_get_items('node', $node_litter, 'field_price_per_young')) { $variables['litter_price_per_young'] = field_view_value('node', $node_litter, 'field_price_per_young', $field_litter_price_per_young[0]); } // Animal if ($field_animal = field_get_items('node', $node_litter, 'field_animal_id')) { $node_animal = node_load($field_animal[0]['target_id']); // Breed if ($field_breed = field_get_items('node', $node_animal, 'field_breed_id')) { $variables['animal_breed'] = field_view_value('node', $node_animal, 'field_breed_id', $field_breed[0]); } } } // User if ($node_creator = ha_user_get_raw_information($variables['user']->uid)) { // Location if (isset($node_creator['location'])) { $variables['user_location'] = $node_creator['location']; } } } }
public function field_view_values($entity_type, $entity, $field_name, $display = array(), $langcode = NULL) { $items = field_get_items($entity_type, $entity, $field_name); if ($items) { $output = array(); foreach ($items as $item) { $output[] = field_view_value($entity_type, $entity, $field_name, $item, $display, $langcode); } return $output; } }
function ssd_preprocess_node(&$variables) { $node = $variables['node']; $variables['title'] = check_plain($node->title); if ($node->type == 'article') { // Get only the first body summary for a module. $body = field_get_items('node', $node, 'body'); $variables['summary'] = field_view_value('node', $node, 'body', $body[0], 'teaser'); $variables['metadata'] = field_view_field('node', $node, 'field_metadata', 'default'); } }
/** * Override or insert variables into the page template. */ function venture_theme_preprocess_page(&$vars) { if (drupal_is_front_page()) { $vars['images'] = array(); $query = db_select('node', 'n')->fields('n', array('nid'))->condition('type', 'slider_item', '=')->range(0, 3)->execute(); $view = $query->fetchAssoc(); foreach ($view as $item) { $node = node_load($item); $image_field = field_get_items('node', $node, 'field_image'); $image = field_view_value('node', $node, 'field_image', $image_field[0], array('type' => 'image', 'settings' => array('image_style' => 'slider_item', 'image_link' => NULL))); $vars['images'][] = $image; } } if (isset($vars['main_menu'])) { $vars['main_menu'] = theme('links__system_main_menu', array('links' => $vars['main_menu'], 'attributes' => array('class' => array('links', 'main-menu', 'clearfix')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible')))); } else { $vars['main_menu'] = FALSE; } if (isset($vars['secondary_menu'])) { $vars['secondary_menu'] = theme('links__system_secondary_menu', array('links' => $vars['secondary_menu'], 'attributes' => array('class' => array('links', 'secondary-menu', 'clearfix')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible')))); } else { $vars['secondary_menu'] = FALSE; } }
<?php $alignment = field_get_items('paragraphs_item', $paragraphs_item, 'field_alignment'); $alignment = empty($alignment[0]['value']) ? 'center' : $alignment[0]['value']; $heading = field_get_items('paragraphs_item', $paragraphs_item, 'field_heading'); $heading = empty($heading[0]['value']) ? '' : $heading[0]['value']; $subheading = field_get_items('paragraphs_item', $paragraphs_item, 'field_subheading'); $subheading = empty($subheading[0]['value']) ? '' : $subheading[0]['value']; $text = field_get_items('paragraphs_item', $paragraphs_item, 'field_text'); $text = empty($text[0]['value']) ? '' : $text[0]['value']; $image = field_get_items('paragraphs_item', $paragraphs_item, 'field_image'); $image_renderable = field_view_value('paragraphs_item', $paragraphs_item, 'field_image', $image[0]); ?> <?php if ($alignment == "center") { ?> <div class="row"> <div class="col-sm-12 center-text"> <?php print render($image_renderable); ?> </div> </div> <div class="row"> <div class="col-sm-12 center-text"> <?php if ($heading) {
<?php } ?> <h5> <?php if (!empty($field_external_author)) { ?> <span style="margin-right:3px;">By:</span> <?php $field = field_get_items('node', $node, 'field_external_author'); print render(field_view_value('node', $node, 'field_external_author', $field[0])); ?> <?php } ?> </h5> <?php print render($content['body']); ?> <a href="<?php $field = field_get_items('node', $node, 'field_external_url'); print render(field_view_value('node', $node, 'field_external_url', $field[0])); ?> " target="_blank">Read Original Article</a> </div> </div> </article> <!-- /.node -->
* - $css_name: A css-safe version of the view name. * - $css_class: The user-specified classes names, if any * - $header: The view header * - $footer: The view footer * - $rows: The results of the view query, if any * - $empty: The empty text to display if the view is empty * - $pager: The pager next/prev links to display, if any * - $exposed: Exposed widget form/info to display * - $feed_icon: Feed icon to display, if any * - $more: A link to view more, if any * * @ingroup views_templates */ $node = node_load($view->result[0]->nid); $image = field_get_items('node', $node, 'field_block_image'); $body = field_get_items('node', $node, 'body'); ?> <div class="row block-wrapper"> <div class="large-7 columns body"> <?php print render(field_view_value('node', $node, 'body', $body[0], array('label' => 'hidden'))); ?> </div> <div class="large-5 columns image large-text-left medium-text-center small-text-center"> <?php print render(field_view_value('node', $node, 'field_block_image', $image[0])); ?> </div> </div> <div class="clearfix"></div>
/** * Implements hook_preprocess_comment(). * * Load user for every comment. */ function loop_preprocess_comment(&$variables) { // Make the content author object available. $variables['comment']->account = user_load($variables['comment']->uid); $variables['comment_author_name'] = _loop_fetch_full_name($variables['comment']->account); $variables['comment_author_image'] = _loop_fetch_author_image($variables['comment']->account); $variables['comment_body'] = _loop_fetch_comment_body($variables['comment']); $comment_author = $variables['comment']->account; if (is_object($comment_author)) { // Load entity wrapper for author. $wrapper = entity_metadata_wrapper('user', $comment_author); // Fetch the fields needed. $variables['place'] = $wrapper->field_location_place->value(); $fetched_job_title = field_get_items('user', $variables['comment']->account, 'field_job_title'); $variables['job_title'] = field_view_value('user', $variables['comment']->account, 'field_job_title', $fetched_job_title[0], array()); } // Fetch files related to the comment. if ($variables['node']->type == 'post') { if (!empty($variables['field_file_upload_comment'])) { $variables['files'] = _loop_fetch_files('comment', $variables['comment']); } } $variables['content']['links']['abuse']['#attributes']['class'] = 'comment--links'; // Remove flag, delete, edit and reply links. unset($variables['content']['links']['comment']['#links']['comment-delete']); unset($variables['content']['links']['comment']['#links']['comment-edit']); unset($variables['content']['links']['flag']); unset($variables['content']['links']['comment']['#links']['comment-reply']); }
function unity_lab_it_preprocess_node_software_title(&$vars, $hook) { $relatedNodeIds = $vars['field_computer_lab_nodes']; $nodeIds = array(); foreach ($relatedNodeIds as $relatedNodeId) { $nodeIds[] = $relatedNodeId['target_id']; } if (count($nodeIds) > 0) { $relatedNodes = entity_load('node', $nodeIds); $items = array(); foreach ($relatedNodes as $relatedNode) { $logo = field_get_items('node', $relatedNode, 'field_logo'); if ($logo) { $logo_render = field_view_value('node', $relatedNode, 'field_logo', $logo[0]); //$logo_render['#item']["attributes"]["class"] = array('flat-circle-image'); $item['image'] = $logo_render; } else { $item['image'] = ''; } $item['url'] = url('node/' . $relatedNode->nid); $item['title'] = $relatedNode->title; $rnIntroduction = field_get_items('node', $relatedNode, 'field_introduction'); $rnIntroduction = empty($rnIntroduction[0]['value']) ? '' : $rnIntroduction[0]['value']; $item['introduction'] = $rnIntroduction; $vars['content']['labs'][] = $item; } } _unity_lab_paragraphs_item_column_classes($vars, $vars['content']['labs'], 1); $view = views_get_view('related_kb_articles'); $output = $view->preview('block_3'); // At least in $view->result is the result. if ($view->result) { $vars['content']['faqView'] = $output; } if (arg(0) == 'node' && is_numeric(arg(1))) { // creating the node variable $node = node_load(arg(1), NULL, TRUE); } $reportProbURL = field_get_items('node', $node, 'field_report_a_problem_url'); $reportProbURL = empty($reportProbURL[0]['url']) ? '' : $reportProbURL[0]['url']; if ($reportProbURL) { $vars['content']['reportProbURL'] = $reportProbURL; } }
<div class="col-lg-7"> <?php $item = field_get_items('node', $node, 'body'); $body = field_view_value('node', $node, 'body', $item[0]); print $body['#markup']; ?> </div> </div> <?php } else { ?> <div class="row"> <div class="col-lg-12"> <?php $item = field_get_items('node', $node, 'body'); $body = field_view_value('node', $node, 'body', $item[0]); print $body['#markup']; ?> </div> </div> <?php } ?> <?php // Hide comments, tags, and links now so that we can render them later. hide($content['comments']); hide($content['links']); hide($content['field_tags']); ?> <?php if (!empty($content['field_tags']) || !empty($content['links'])) {
<h2><b>Related Publications</b></h2> <div> <?php $field_store_reference = field_get_items('node', $node, 'field_docum_related_publications'); $render_array = field_view_value('node', $node, 'field_docum_related_publications', $field_store_reference[0]); echo "<br>"; print render($render_array); ?> </div> <h2><b>Related Documents and Media</b></h2> <div> <?php $field_store_reference = field_get_items('node', $node, 'field_docum_related_publications'); $render_array = field_view_value('node', $node, 'field_docum_related_publications', $field_store_reference[0]); echo "<br>"; print render($render_array); ?> </div> <div class="des-bottom"> <b>Research Topics:</b> <?php // print render(field_view_field('node', $node, 'field_document_rits')); ?> <br> <b>National Strategic Program Areas:</b> Wildland Fire and Fuels<br> <b>Priority Research Area: </b> Sxxxxxxxxxxxxx<br> <b>PNW Research Programs: </b>
} ?> <?php } ?> <?php if (isset($content['sharethis'])) { ?> <?php print render($content['sharethis']); ?> <?php } ?> </div> <div class="w-col w-col-8"> <?php foreach ($multimedia as $key => $value) { $pid = $value['value']; $data = field_view_value('node', $node, 'field_portfolio_multimedia', $multimedia[$key]); ?> <?php print render($data['entity']['field_collection_item'][$pid]['field_portfolio_multi_image']); ?> <?php } ?> </div>
<?php $image = ''; if (!empty($node->field_video)) { $field_video = field_get_items('node', $node, 'field_video'); $field_custom_video_thumbnail = field_get_items('node', $node, 'field_custom_video_thumbnail'); if (!empty($field_custom_video_thumbnail[0]['uri'])) { $image_item = array('style_name' => $thumb_image_style, 'path' => $field_custom_video_thumbnail[0]['uri'], 'alt' => $node->title, 'title' => $node->title); $image = theme('image_style', $image_item); } else { $field_video_view_value = field_view_value('node', $node, 'field_video', $field_video[0]); $field_video_view_value['#theme'] = 'video_formatter_thumbnail'; $field_video_view_value['#image_style'] = $thumb_image_style; $image = render($field_video_view_value); } } $node_url = url('node/' . $node->nid); $name = bizutv_helper_get_user_name($node->uid); $display_name = l($name, 'user/' . $node->uid); $duration = bizutv_helper_get_duration($node->field_video['und'][0]['fid']); $likes_display = ''; if ($likes) { $rate_results = rate_get_results('node', $node->nid, 1); $likes_display = $rate_results['up']; } $views_display = ''; if ($views) { $hits = bizutv_video_get_node_hits($node->nid); $views_display = $hits . ' view' . ($hits == 1 ? '' : 's'); } $time_ago_display = '';
size-<?php print $banner_height_value; ?> "> <div class="banner-image" style="<?php $files_dir = variable_get('file_public_path', conf_path() . '/files'); if (!empty($field_image)) { print 'background-image:url(/' . $files_dir . '/banners/' . $field_image[0]['filename'] . ');'; } ?> "> <?php if (!empty($field_banner_text)) { ?> <div class="container label-wrapper"> <h2> <?php $field = field_get_items('node', $node, 'field_banner_text'); print render(field_view_value('node', $node, 'field_banner_text', $field[0])); ?> </h2> </div> <?php } ?> </div> </div>
<?php if (isset($content['field_gallery'])) { // ?> <?php $images = field_get_items('node', $node, 'field_gallery'); ?> <?php $gallery = array(); if ($images && !$is_front) { foreach ($images as $img) { $gallery[] = field_view_value('node', $node, 'field_gallery', $img, array('type' => 'image', 'settings' => array('image_style' => 'large'))); } print render($galeria); } ?> <?php } } else { print render($page['content']); } ?> </section> </div>
<?php $image = field_get_items('node', $node, 'field_image'); if ($image) { $imgOutput = field_view_value('node', $node, 'field_image', $image[0], array('type' => 'image', 'settings' => array('image_style' => 'thumbnail'))); } ?> <div class="col-"> <div id="node-article-list" class="node-article-list"> <h4> <a href="<?php print $node_url; ?> "> <span class="data"> <?php print format_date($node->created, 'custom', 'j/m/Y'); ?> </span> <?php print $title; ?> </a> </h4> <p> <a href="<?php print $node_url;
<?php // save fields to local variables $item_hero_text = field_get_items('node', $node, 'field_hero_text'); $hero_text = field_view_value('node', $node, 'field_hero_text', $item_hero_text[0]); // get link $hero_link = field_get_items('node', $node, 'field_hero_link'); $link = $hero_link[0]; // get an image's URL $item_hero_image = field_get_items('node', $node, 'field_hero_image'); $hero_image = $item_hero_image[0]['uri']; $hero_image_url = file_create_url($hero_image); $item_body = field_get_items('node', $node, 'body'); $body = field_view_value('node', $node, 'body', $item_body[0]); $pathways = field_get_items('node', $node, 'field_pathways'); $item_video_section_text = field_get_items('node', $node, 'field_video_section_text'); $video_section_text = field_view_value('node', $node, 'field_video_section_text', $item_video_section_text[0]); // get plain text $item_overview_video = field_get_items('node', $node, 'field_youtube_embed_url'); $overview_video = $item_overview_video[0]['value']; $related_pages = field_get_items('node', $node, 'field_related_pages'); $main_image = $hero_image_url; $field_summary = field_view_field('node', $node, 'field_video_section_text', array('label' => 'hidden', 'type' => 'text_summary_or_trimmed', 'settings' => array())); // give it a big clean out $summary = html_entity_decode(preg_replace("/ /i", " ", htmlentities(strip_tags($field_summary[0]['#markup'])))); $summary = preg_replace('/"/', "'", $summary); $summary = preg_replace("/(\r?\n){2,}/", ' ', $summary); $inline_script = '' . '<meta property="og:title" content="' . variable_get('site_name', '') . ' – The University of Melbourne" />' . '<meta property="og:image" content="' . $main_image . '" />' . '<meta property="og:description" content="' . trim($summary) . '" />' . '<meta name="twitter:card" content="summary" />' . '<meta name="twitter:site" content="@msdsocial" />' . '<meta name="twitter:creator" content="@msdsocial" />' . ''; $element = array('#type' => 'markup', '#markup' => $inline_script); drupal_add_html_head($element, 'fb ogs'); ?>
/** * Loads a drupal field collection in a single function call * * @author Arika Prime * @param string $fieldCollectionName drupal field collection machine name * @param object $node is teh node object - leave null for current node. * @return mixed[] The value of the field collection. This will return value in the order that they are entered in Drupal Admin */ function mos_getFieldCollectionValue($fieldCollectionName, $node = null) { $node = mos_node($node); $valueArray = array(); $fieldCollection = field_get_items('node', $node, $fieldCollectionName); if (!empty($fieldCollection)) { foreach ($fieldCollection as $fieldCollectionKey => $fieldCollectionValue) { $field = field_view_value('node', $node, $fieldCollectionName, $fieldCollectionValue); $fieldName = array(); // Parse array to pull out the field labels of the fields within the field collection $fieldCollectionItemIndex = $fieldCollectionKey + 1; foreach ($field['entity']['field_collection_item'] as $id => $fieldCollection) { foreach ($fieldCollection as $key => $value) { if (!preg_match("/\\#/", $key)) { $fieldName[] = $key; } } // load the field collection item entity $fieldCollectionItem = field_collection_item_load($id); // wrap the entity and make it easier to get the values of fields $fieldWrapper = entity_metadata_wrapper('field_collection_item', $fieldCollectionItem); // store values in array which will be returned at end of function foreach ($fieldName as $index => $name) { $valueArray[$fieldCollectionKey][$name] = $fieldWrapper->{$name}->value(); } } } } return $valueArray; }
<div class="tfa-block"> <h3>Random From Categories</h3> <div id="tfa-owl" class="owl-carousel"> <?php foreach ($vars as $var) { $node = node_load($var->nid); $files = field_get_items('node', $node, 'field_parent_list_slide_image'); if (!empty($files)) { foreach ($files as $keys => $value) { $imageOutput = field_view_value('node', $node, 'field_parent_list_slide_image', $files[$keys], array('type' => 'image', 'settings' => array('image_style' => 'main_factsthumb', 'image_link' => 'content'))); } } ?> <div class="item"> <article class="tfa-block tfa-block-article"> <figure> <div class="tfa-article-link-overlay"> <?php echo l('', 'node/' . $node->nid, array('attributes' => array('class' => array('tfa-icon', 'tfa-icon-link')))); ?> </div>
.slick-prev:before, .slick-next:before { font-size: 40px; color: greenyellow; /*to notice it, is white*/ } .slick-prev { left: 40px; } .slick-next { right: 40px; } </style> <div class="homepage-slider"> <?php foreach ($slides as $slide) { ?> <div> <?php $image = field_get_items('node', $slide, 'field_image'); $output = field_view_value('node', $slide, 'field_image', $image[0], array('type' => 'image', 'settings' => array('image_style' => 'slider_homepage'))); echo render($output); ?> </div> <?php } ?> </div>
/** * Implements hook_preprocess_reply(). */ function dguk_preprocess_reply(&$variables) { global $user; if ($user->uid && $user->uid == $variables['reply']->uid) { $variables['classes_array'][] = 'own-reply'; } $variables['classes_array'][] = 'boxed'; $variables['classes_array'][] = 'parent-' . $variables['reply']->parent; // Add $avatar variable with rendered user picture linked to user profile; $fields = field_info_instances('user', 'user'); $field_id = $fields['field_avatar']['field_id']; $account = new stdClass(); $account->uid = $variables['reply']->uid; field_attach_load('user', array($account->uid => $account), FIELD_LOAD_CURRENT, array('field_id' => $field_id)); if (!empty($account->field_avatar)) { $field = field_get_items('user', $account, 'field_avatar'); $image = field_view_value('user', $account, 'field_avatar', $field[0], array('settings' => array('image_style' => 'avatar'))); } else { $image_info = dguk_default_field_image('field_avatar'); $image = field_view_value('user', $account, 'field_avatar', (array) $image_info, array('settings' => array('image_style' => 'avatar'))); } $colour = $variables['reply']->uid % 10; if ($variables['reply']->uid) { $variables['avatar'] = l(render($image), 'user/' . $variables['reply']->uid, array('html' => true, 'attributes' => array('class' => array('field-avatar', 'bg-colour-' . $colour)))); } else { $variables['avatar'] = '<div class="field-avatar bg-colour-0">' . render($image) . '</div>'; } $variables['theme_hook_suggestions'][] = 'reply__' . $variables['bundle']; }
if (!empty($node) && $node->type=='projects' ) { $nodeType = substr($node->type,0); $field_text = field_get_items('node', $node, 'field_sub_text_projects'); $subtext = field_view_value('node', $node, 'field_sub_text_projects', $field_text[0]); $field = field_get_items('node', $node, 'field_images_title_projects'); $bannerImage = field_view_value('node', $node, 'field_images_title_projects', $field[0]); } else if(isset($node->field_title_sub_text1) || isset($node->field_images_title)) { $field_text = field_get_items('node', $node, 'field_title_sub_text1'); $subtext = field_view_value('node', $node, 'field_title_sub_text1', $field_text[0]); $field = field_get_items('node', $node, 'field_images_title'); $bannerImage = field_view_value('node', $node, 'field_images_title', $field[0]); } ?> <div id="header-text"><h1 class="title" id="page-title"><?php print $title; ?></h1> <div class="subtext"><?php print render($subtext); ?></div> </div> <?php if(isset($node->field_images_title)|| isset($node->field_images_title_projects)): ?> <div id="header-image"> <?php print render($bannerImage); ?> </div> </div>
<?php switch ($config['depth']) { case 1: // children echo "<section class='navigation-block-listing'><ul class=''>"; foreach ($content as $menu_item) { if (isset($menu_item['#title'])) { $nid = (int) str_replace("node/", "", $menu_item['#href']); $delta = 0; $language = 'und'; $entity = entity_load('node', array($nid)); if (isset($entity[$nid])) { $node_curr = $entity[$nid]; $item_summary = field_get_items('node', $node_curr, 'field_summary'); if ($item_summary) { $node_curr_summary = field_view_value('node', $node_curr, 'field_summary', $item_summary[0]); } else { $node_curr_summary = field_view_field('node', $node_curr, 'body', array('label' => 'hidden', 'type' => 'text_summary_or_trimmed', 'settings' => array('trim_length' => 150))); } echo '<li><a href="/' . drupal_get_path_alias($menu_item['#href']) . '">' . "<h3>" . $menu_item['#title'] . "</h3>"; print render($node_curr_summary); echo '</a></li>'; } } } echo "</ul></section>"; break; case 2: // grandchildren echo "<section class='navigation-block-listing'><ul class='narrow'>"; foreach ($content as $menu_item) {
* - $css_name: A css-safe version of the view name. * - $css_class: The user-specified classes names, if any * - $header: The view header * - $footer: The view footer * - $rows: The results of the view query, if any * - $empty: The empty text to display if the view is empty * - $pager: The pager next/prev links to display, if any * - $exposed: Exposed widget form/info to display * - $feed_icon: Feed icon to display, if any * - $more: A link to view more, if any * * @ingroup views_templates */ $node = node_load($view->result[0]->nid); $image = field_get_items('node', $node, 'field_block_image'); $body = field_get_items('node', $node, 'body'); ?> <div class="row block-wrapper"> <div class="large-5 columns image large-text-left medium-text-center small-text-center"> <?php print render(field_view_value('node', $node, 'field_block_image', $image[0])); ?> </div> <div class="large-7 columns body"> <?php print render(field_view_value('node', $node, 'body', $body[0], array('label' => 'hidden'))); ?> </div> </div> <div class="clearfix"></div>
<?php $image = field_get_items('node', $node, 'field_image'); ?> <?php if ($image) { $imgOutput = field_view_value('node', $node, 'field_image', $image[0], array('type' => 'image', 'settings' => array('image_style' => $is_front ? 'medium' : 'side'))); } ?> <a href="<?php print $node_url; ?> "> <?php print render($imgOutput); ?> </a>
<?php } ?> </ul> </div> <!-- EOF:#internal-banner-slider --> <?php if ($numberOfImages > 1) { ?> <!-- #internal-slider-carousel --> <div id="internal-slider-carousel" class="flexslider"> <ul class="slides"> <?php foreach ($thumbnails as $key => $file) { $thumbnail = field_view_value('node', $node, 'field_mt_banner_image', $thumbnails[$key], array('type' => 'image', 'settings' => array('image_style' => 'mt_thumbnails'))); ?> <li> <?php print render($thumbnail); ?> </li> <?php } ?> </ul> </div> <!-- EOF:#internal-slider-carousel --> <?php }
<?php /** * @file * Custom group node template. */ if ($teaser) { ?> <?php $node = node_load($nid); // Group image. $image = field_get_items('node', $node, 'field_image'); if ($image) { $group_logo = field_view_value('node', $node, 'field_image', $image[0], array('type' => 'image', 'settings' => array('image_style' => 'group_medium', 'image_link' => 'content'))); } ?> <article class="node-teaser"> <div class="field-name-field-image"><?php print render($group_logo); ?> </div> <h2 class="node-title"><a href="<?php print $node_url; ?> " title="<?php print $title; ?> "><?php print $title; ?>
/** * Override or insert variables into the page template. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("page" in this case.) */ function unity_lab_preprocess_page(&$vars) { if (isset($vars['node'])) { $path = $_GET['q']; if (substr($path, -6) === '/draft') { $vars['node'] = workbench_moderation_node_current_load($vars['node']); } // dpm($wbm); $vars['theme_hook_suggestions'][] = 'page__sections'; $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type; $vars['theme_hook_suggestions'][] = 'page__node__' . $vars['node']->nid; //get hero section from node; $hero = field_get_items('node', $vars['node'], 'field_hero_section'); if ($hero) { $heroRender = field_view_value('node', $vars['node'], 'field_hero_section', $hero[0]); $vars['page']['banner'] = $heroRender; } else { //if there is no hero defined, then clear banner. $vars['page']['banner'] = ''; } $introduction = field_get_items('node', $vars['node'], 'field_introduction'); if (!empty($introduction)) { $introduction = field_view_value('node', $vars['node'], 'field_introduction', $introduction[0]); $vars['page']['introduction'] = render($introduction); } else { $vars['page']['introduction'] = ''; } $audDisplay = array('label' => 'hidden', 'type' => 'textformatter_list', 'settings' => array('textformatter_class' => 'textformatter-list', 'textformatter_comma_and' => 1, 'textformatter_comma_full_stop' => 0, 'textformatter_comma_override' => 0, 'textformatter_comma_tag' => '', 'textformatter_contrib' => array(), 'textformatter_separator_custom' => '', 'textformatter_separator_custom_class' => '', 'textformatter_separator_custom_tag' => 'span', 'textformatter_term_plain' => 1, 'textformatter_type' => 'comma')); $audience = field_get_items('node', $vars['node'], 'field_audience'); $audience = field_view_field('node', $vars['node'], 'field_audience', $audDisplay); if (!empty($audience)) { $audience = render($audience); $vars['page']['introduction'] .= '<p>Audience: ' . $audience . '</p>'; } /* $audDisplay = array('type'=>'plaintext'); if(!empty($audience)) { $audienceString = ''; foreach($audience as $audienceItem) { $audienceItem = field_view_value('node', $vars['node'], 'field_audience', $audienceItem, $audDisplay); dpm($audienceItem); $audienceString .= render($audienceItem) . ", "; } $audienceString = rtrim($audienceString, ', '); */ // $vars['page']['introduction'] .= '<p><strong>Audience:</strong> ' . $audienceString . '</p>'; // } $jumpMenu = field_get_items('node', $vars['node'], 'field_jump_menu'); if (!empty($jumpMenu)) { $vars['page']['jump-menu']['type'] = $jumpMenu[0]['value']; unity_lab_jump_menu($vars); } else { $vars['page']['jump-menu'] = ''; } } else { if (!empty($vars['page']['main_prefix']) && !empty($vars['page']['main_postfix'])) { $vars['theme_hook_suggestions'][] = 'page__three_col'; } else { if (!empty($vars['page']['main_postfix'])) { $vars['theme_hook_suggestions'][] = 'page__postfix'; } else { if (!empty($vars['page']['main_prefix'])) { $vars['theme_hook_suggestions'][] = 'page__prefix'; } else { $vars['theme_hook_suggestions'][] = 'page'; } } } } }
function theme_preprocess_page(&$variables) { $status = drupal_get_http_header("status"); if ($status == "404 Not Found") { $variables['theme_hook_suggestions'][] = 'page__404'; } if ($status == "403 Forbidden") { $variables['theme_hook_suggestions'][] = 'page__403'; } if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) { unset($variables['page']['content']['system_main']['term_heading']['#prefix']); unset($variables['page']['content']['system_main']['term_heading']['#suffix']); } //if(isset($variables['node']) && $variables['node']->type == "your_content_type") { //drupal_set_title("my_title"); //} $variables['page']['titleclass'] = 'title__about'; //dpm($variables); if (isset($variables['node'])) { if (isset($variables['node']->field_descr)) { $field_descr = field_get_items('node', $variables['node'], 'field_descr'); $variables['page']['descr'] = field_view_value('node', $variables['node'], 'field_descr', $field_descr[0]); } if ($variables['node']->type == 'info') { $variables['page']['titleclass'] = 'title__info'; $voc = taxonomy_vocabulary_load(5); if (isset($voc->field_descr)) { $field_descr = field_get_items('taxonomy_vocabulary', $voc, 'field_descr'); $variables['page']['descr'] = field_view_value('taxonomy_vocabulary', $voc, 'field_descr', $field_descr[0]); } } } else { if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) { $variables['page']['titleclass'] = 'title__tarifs'; } else { if (function_exists('views_get_page_view') && views_get_page_view()) { $view = views_get_page_view(); //dpm($view); if ($view->name == 'tarifs') { $variables['page']['titleclass'] = 'title__tarifs'; $voc = taxonomy_vocabulary_load(2); if (isset($voc->field_descr)) { $field_descr = field_get_items('taxonomy_vocabulary', $voc, 'field_descr'); $variables['page']['descr'] = field_view_value('taxonomy_vocabulary', $voc, 'field_descr', $field_descr[0]); } } else { if ($view->name == 'info') { $variables['page']['titleclass'] = 'title__info'; $voc = taxonomy_vocabulary_load(5); if (isset($voc->field_descr)) { $field_descr = field_get_items('taxonomy_vocabulary', $voc, 'field_descr'); $variables['page']['descr'] = field_view_value('taxonomy_vocabulary', $voc, 'field_descr', $field_descr[0]); } } else { if ($view->name == 'contacts') { $variables['page']['titleclass'] = 'title__contact'; $voc = taxonomy_vocabulary_load(3); if (isset($voc->field_descr)) { $field_descr = field_get_items('taxonomy_vocabulary', $voc, 'field_descr'); $variables['page']['descr'] = field_view_value('taxonomy_vocabulary', $voc, 'field_descr', $field_descr[0]); } } else { if ($view->name == 'price') { $variables['page']['titleclass'] = 'title__price'; $voc = taxonomy_vocabulary_load(4); if (isset($voc->field_descr)) { $field_descr = field_get_items('taxonomy_vocabulary', $voc, 'field_descr'); $variables['page']['descr'] = field_view_value('taxonomy_vocabulary', $voc, 'field_descr', $field_descr[0]); } } } } } } } } }
function medtravel_preprocess_html(&$vars) { // loads entity data $url_params = current_path(); $params = explode('/', $url_params); // if belongs to micro entity type if ($params[0] == 'micro') { // loads entity $id = $params[1]; $entity = entity_load('micro', array($id)); if (!empty($entity)) { $vars['entity_not_found'] = false; $entity = $entity[$id]; $title = field_get_items('micro', $entity, 'field_res_title'); $title = field_view_value('micro', $entity, 'field_res_title', $title[0]); $title = $title['#markup']; $description = field_get_items('micro', $entity, 'field_res_description'); $description = field_view_value('micro', $entity, 'field_res_description', $description[0]); $description = $description['#markup']; $img = field_get_items('micro', $entity, 'field_res_img'); $img = field_view_value('micro', $entity, 'field_res_img', $img[0]); $img = file_load($img['#item']['fid']); $img = file_create_url($img->uri); //$img = $img->source; // configure og's $vars['og_title'] = $title; $vars['og_description'] = $description; $vars['og_img'] = $img; } else { $variables['entity_not_found'] == true; } } }