|
5 | 5 | if (array_key_exists('field_link', $content)):
|
6 | 6 | hide($content['field_link']);
|
7 | 7 |
|
| 8 | + // get field data |
| 9 | + $field = field_get_items('node', $node, 'field_link'); |
| 10 | + $link_value = field_view_value('node', $node, 'field_link', $field[0]); |
| 11 | + |
8 | 12 | // Build link with querystring and fragment
|
9 | 13 | $options = array (
|
10 |
| - 'fragment' => $node->field_link[0]['fragment'], |
11 |
| - 'query' => $node->field_link[0]['query'], |
| 14 | + 'fragment' => $link_value['#element']['fragment'], |
| 15 | + 'query' => $link_value['#element']['query'], |
12 | 16 | );
|
13 |
| - $url = url($node->field_link[0]['url'], $options); |
| 17 | + $url = url($link_value['#element']['url'], $options); |
14 | 18 |
|
15 | 19 | // If the link has no title or is read more, set to read more with context for screen-readers
|
16 |
| - $original_title = $node->field_link[0]['original_title']; |
| 20 | + $original_title = $link_value['#element']['original_title']; |
17 | 21 | if(empty(trim($original_title)) || strcasecmp(trim($original_title), "Read more") == 0):
|
18 | 22 | $read_more = t('Read more') . '<span class="element-invisible"> at: ' . $title . '</span>';
|
19 | 23 | else:
|
|
24 | 28 | $content['field_image'][0]['#path'] = array('path' => $url);
|
25 | 29 | endif;
|
26 | 30 | else:
|
| 31 | + if ($type == 'link'): |
| 32 | + $url = NULL; |
| 33 | + else: |
27 | 34 | $url = $node_url;
|
28 | 35 | $read_more = t('Read more') . '<span class="element-invisible"> at: ' . $title . '</span>';
|
| 36 | + endif; |
29 | 37 | endif;
|
30 | 38 |
|
31 | 39 | $has_image = isset($content['field_image']);
|
| 40 | +$has_url = isset($url); |
32 | 41 |
|
33 |
| -if ($has_image && isset($url)): |
34 |
| - if(isset($content['field_image'][0]['#item']) && empty($content['field_image'][0]['#item']['alt']) ): |
35 |
| - $content['field_image'][0]['#item']['alt'] = $read_more . t(' at: ') . $title; |
36 |
| - endif; |
| 42 | +// We will have a single link for the teaser so ensure the image itself isn't linked |
| 43 | +if ($has_image): |
| 44 | + unset($content['field_image'][0]['#path']); |
37 | 45 | endif;
|
38 | 46 |
|
39 | 47 | ?>
|
40 | 48 |
|
41 | 49 | <div class="campl-content-container <?php print $classes; ?>" <?php print $attributes; ?>>
|
42 | 50 | <div class="campl-vertical-teaser campl-teaser campl-promo-teaser">
|
43 |
| - <div class="campl-content-container campl-vertical-teaser-txt"> |
44 |
| - <?php print render($title_prefix); ?> |
45 |
| - <p class='campl-teaser-title'><a href="<?php print $url; ?>"><?php print $title; ?></a></p> |
46 |
| - <?php print render($title_suffix); ?> |
47 |
| - </div> |
48 |
| - <?php if ($has_image): ?> |
49 |
| - <div class="campl-content-container campl-vertical-teaser-img"> |
50 |
| - <?php print render($content['field_image']); ?> |
| 51 | + <?php print render($title_prefix); ?> |
| 52 | + |
| 53 | + <?php if ($has_url): ?> |
| 54 | + <a href="<?php print $url; ?>"> |
| 55 | + <span class="campl-secondary-cta teaser-cta-button campl-float-right"><?php print $read_more; ?></span> |
| 56 | + <?php endif; ?> |
| 57 | + |
| 58 | + <div class="campl-content-container campl-vertical-teaser-txt"> |
| 59 | + <h2 class='campl-teaser-title'><?php print $title; ?></h2> |
51 | 60 | </div>
|
| 61 | + |
| 62 | + <?php if ($has_image): ?> |
| 63 | + <div class="campl-content-container campl-vertical-teaser-img"> |
| 64 | + <?php print render($content['field_image']); ?> |
| 65 | + </div> |
| 66 | + <?php endif; ?> |
| 67 | + |
| 68 | + <?php if ($has_url): ?> |
| 69 | + </a> |
52 | 70 | <?php endif; ?>
|
| 71 | + |
53 | 72 | <div class="campl-content-container<?php if (!$has_image): print ' campl-no-top-padding'; endif; ?> campl-vertical-teaser-txt clearfix">
|
54 | 73 | <?php if ($display_submitted): ?>
|
55 | 74 | <p class="campl-datestamp"><?php print $date; ?></p>
|
56 | 75 | <?php endif; ?>
|
57 | 76 | <?php print render($content); ?>
|
58 |
| - <a href="<?php print $url; ?>" class="campl-secondary-cta campl-float-right"><?php print $read_more; ?></a> |
| 77 | + |
59 | 78 | </div>
|
| 79 | + <?php print render($title_suffix); ?> |
60 | 80 | </div>
|
61 | 81 | </div>
|
0 commit comments