Skip to content

Commit 1a39bfb

Browse files
authored
Merge pull request #24 from misd-service-development/devoct2
Devoct2
2 parents b9931ba + bf9b29b commit 1a39bfb

7 files changed

+175
-63
lines changed

cambridge_teasers.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = Teasers
22
description = Adds University of Cambridge theme teasers node view modes.
33
core = 7.x
44
package = University of Cambridge
5-
version = 7.x-1.7
5+
version = 7.x-1.8
66
project = cambridge_teasers
77
dependencies[] = cambridge_image_styles
88
dependencies[] = features

css/teasers.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
.campl-teaser {
2+
position: relative;
3+
top: 0;
4+
left: 0;
5+
}
6+
17
.campl-teaser p.campl-datestamp {
28
color: #777777;
39
background: none;
@@ -26,6 +32,44 @@
2632
border-right: 0;
2733
}
2834

35+
.campl-primary-cta.teaser-cta-button {
36+
position: absolute;
37+
bottom: 0;
38+
right: 20px;
39+
}
40+
41+
.campl-horizontal-teaser .campl-horizontal-teaser-txt,
42+
.campl-vertical-teaser .campl-vertical-teaser-txt {
43+
padding-bottom: 2rem;
44+
}
45+
46+
.campl-focus-teaser-txt .campl-teaser-title {
47+
color: white;
48+
}
49+
50+
.campl-promo-teaser .campl-secondary-cta {
51+
position: absolute;
52+
bottom: 10px;
53+
right: 20px;
54+
}
55+
56+
.campl-promo-teaser .campl-teaser-title {
57+
color: black;
58+
}
59+
60+
.campl-promo-teaser a:hover {
61+
text-decoration: none;
62+
}
63+
64+
.campl-promo-teaser a .campl-teaser-title:hover {
65+
color: black;
66+
text-decoration: underline;
67+
}
68+
69+
.campl-promo-teaser a .teaser-cta-button:hover {
70+
text-decoration: underline;
71+
}
72+
2973
@media (min-width: 768px) {
3074
.campl-hide-teaser-divider .campl-teaser-divider {
3175
display: none;

templates/node----focus-on-teaser.tpl.php

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
if (array_key_exists('field_link', $content)):
66
hide($content['field_link']);
77

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+
812
// Build link with querystring and fragment
913
$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'],
1216
);
13-
$url = url($node->field_link[0]['url'], $options);
17+
$url = url($link_value['#element']['url'], $options);
1418

1519
// 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'];
1721
if(empty(trim($original_title)) || strcasecmp(trim($original_title), "Read more") == 0):
1822
$read_more = t('Read more') . '<span class="element-invisible"> at: ' . $title . '</span>';
1923
else:
@@ -24,36 +28,51 @@
2428
$content['field_image'][0]['#path'] = array('path' => $url);
2529
endif;
2630
else:
27-
$url = $node_url;
28-
$read_more = t('Read more') . '<span class="element-invisible"> at: ' . $title . '</span>';
31+
if ($type == 'link'):
32+
$url = NULL;
33+
else:
34+
$url = $node_url;
35+
$read_more = t('Read more') . '<span class="element-invisible"> at: ' . $title . '</span>';
36+
endif;
2937
endif;
3038

3139
$has_image = isset($content['field_image']);
40+
$has_url = isset($url);
3241

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']);
3745
endif;
3846

3947
?>
4048

4149
<div class="campl-content-container campl-side-padding <?php print $classes; ?>" <?php print $attributes; ?>>
4250
<div class="campl-horizontal-teaser campl-teaser clearfix campl-focus-teaser">
51+
<?php print render($title_prefix); ?>
52+
53+
<?php if ($has_url): ?>
54+
<a href="<?php print $url; ?>">
55+
<span class="ir campl-focus-link"><?php print $read_more; ?></span>
56+
<?php endif; ?>
57+
4358
<div class="campl-focus-teaser-img">
4459
<div class="campl-content-container campl-horizontal-teaser-img">
4560
<?php if ($has_image): ?>
4661
<?php print render($content['field_image']); ?>
4762
<?php endif; ?>
4863
</div>
4964
</div>
65+
5066
<div class="campl-focus-teaser-txt">
5167
<div class="campl-content-container campl-horizontal-teaser-txt">
52-
<?php print render($title_prefix); ?>
53-
<h3 class="campl-teaser-title"><a href="<?php print $url; ?>"><?php print $title; ?></a></h3>
54-
<?php print render($title_suffix); ?>
55-
<a href="<?php print $url; ?>" class="ir campl-focus-link"><?php print $read_more; ?></a>
68+
<h3 class="campl-teaser-title"><?php print $title; ?></h3>
5669
</div>
5770
</div>
71+
72+
<?php if ($has_url): ?>
73+
</a>
74+
<?php endif; ?>
75+
76+
<?php print render($title_suffix); ?>
5877
</div>
5978
</div>

templates/node----news-listing-item.tpl.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
<?php
2-
32
hide($content['links']);
43

54
if (array_key_exists('field_link', $content)):
65
hide($content['field_link']);
6+
7+
// get field data
8+
$field = field_get_items('node', $node, 'field_link');
9+
$link_value = field_view_value('node', $node, 'field_link', $field[0]);
10+
711
// Build link with querystring and fragment
812
$options = array (
9-
'fragment' => $node->field_link[0]['fragment'],
10-
'query' => $node->field_link[0]['query'],
13+
'fragment' => $link_value['#element']['fragment'],
14+
'query' => $link_value['#element']['query'],
1115
);
12-
$url = url($node->field_link[0]['url'], $options);
16+
$url = url($link_value['#element']['url'], $options);
1317
else:
1418
$url = $node_url;
1519
endif;

templates/node----sidebar-teaser.tpl.php

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
if (array_key_exists('field_link', $content)):
66
hide($content['field_link']);
77

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+
812
// Build link with querystring and fragment
913
$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'],
1216
);
13-
$url = url($node->field_link[0]['url'], $options);
17+
$url = url($link_value['#element']['url'], $options);
1418

1519
// 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'];
1721
if(empty(trim($original_title)) || strcasecmp(trim($original_title), "Read more") == 0):
1822
$read_more = t('Read more') . '<span class="element-invisible"> at: ' . $title . '</span>';
1923
else:
@@ -24,38 +28,54 @@
2428
$content['field_image'][0]['#path'] = array('path' => $url);
2529
endif;
2630
else:
31+
if ($type == 'link'):
32+
$url = NULL;
33+
else:
2734
$url = $node_url;
2835
$read_more = t('Read more') . '<span class="element-invisible"> at: ' . $title . '</span>';
36+
endif;
2937
endif;
3038

3139
$has_image = isset($content['field_image']);
40+
$has_url = isset($url);
3241

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']);
3745
endif;
3846

3947
?>
4048

4149
<div class="campl-content-container <?php print $classes; ?>" <?php print $attributes; ?>>
4250
<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>
5160
</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>
5270
<?php endif; ?>
71+
5372
<div class="campl-content-container<?php if (!$has_image): print ' campl-no-top-padding'; endif; ?> campl-vertical-teaser-txt clearfix">
5473
<?php if ($display_submitted): ?>
5574
<p class="campl-datestamp"><?php print $date; ?></p>
5675
<?php endif; ?>
5776
<?php print render($content); ?>
58-
<a href="<?php print $url; ?>" class="campl-secondary-cta campl-float-right"><?php print $read_more; ?></a>
77+
5978
</div>
79+
<?php print render($title_suffix); ?>
6080
</div>
6181
</div>

templates/node----teaser.tpl.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
if (array_key_exists('field_link', $content)):
66
hide($content['field_link']);
77

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+
812
// Build link with querystring and fragment
913
$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'],
1216
);
13-
$url = url($node->field_link[0]['url'], $options);
17+
$url = url($link_value['#element']['url'], $options);
1418

1519
// 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'];
1721
if(empty(trim($original_title)) || strcasecmp(trim($original_title), "Read more") == 0):
1822
$read_more = t('Read more') . '<span class="element-invisible"> at: ' . $title . '</span>';
1923
else:
@@ -33,36 +37,43 @@
3337
endif;
3438

3539
$has_image = isset($content['field_image']);
40+
$has_url = isset($url);
3641

37-
if ($has_image && isset($url)):
38-
if(isset($content['field_image'][0]['#item']) && empty($content['field_image'][0]['#item']['alt']) ):
39-
$content['field_image'][0]['#item']['alt'] = $read_more . t(' at: ') . $title;
40-
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']);
4145
endif;
42-
4346
?>
4447

45-
<div class="campl-content-container campl-vertical-padding <?php print $classes; ?>" <?php print $attributes; ?>>
48+
<div class="campl-vertical-padding <?php print $classes; ?>" <?php print $attributes; ?>>
4649
<div class="campl-horizontal-teaser campl-teaser campl-teaser-border campl-content-container campl-side-padding clearfix">
50+
51+
<?php if ($has_url): ?>
52+
<a href="<?php print $url; ?>">
53+
<div class="campl-primary-cta teaser-cta-button"><?php print $read_more; ?></div>
54+
<?php endif; ?>
55+
4756
<?php if ($has_image): ?>
4857
<div class="campl-column6">
4958
<div class="campl-content-container campl-horizontal-teaser-img">
5059
<?php print render($content['field_image']); ?>
5160
</div>
5261
</div>
5362
<?php endif; ?>
63+
64+
<?php if ($has_url): ?>
65+
</a>
66+
<?php endif; ?>
67+
5468
<div class="campl-column<?php if ($has_image): ?>6<?php else: ?>12<?php endif; ?>">
5569
<div class="campl-content-container <?php if (!$has_image): ?>campl-no-padding<?php endif; ?> campl-horizontal-teaser-txt">
5670
<?php print render($title_prefix); ?>
57-
<h3 class='campl-teaser-title'><a href="<?php print $url; ?>"><?php print $title; ?></a></h3>
71+
<h3 class='campl-teaser-title'><?php print $title; ?></h3>
5872
<?php print render($title_suffix); ?>
5973
<?php if ($display_submitted): ?>
6074
<p class="campl-datestamp"><?php print $date; ?></p>
6175
<?php endif; ?>
6276
<?php print render($content); ?>
63-
<?php if ($url): ?>
64-
<a href="<?php print $url; ?>" class="campl-primary-cta"><?php print $read_more; ?></a>
65-
<?php endif; ?>
6677
</div>
6778
</div>
6879
</div>

0 commit comments

Comments
 (0)