Skip to content

Commit 29491c4

Browse files
authored
Merge pull request #97 from misd-service-development/7.x-1.8
7.x 1.8 * Updated the theme to take into account the changes in the latest version of Easy Breadcrumb module 7.x-2.13. Their theme layer has changed completely and we have had to match the changes to allow us to continue to use easy breadcrumb in some Cambridge sites. If you are using easy breadcrumb prior to 7.x-2.13 you will need to upgrade to this version of the module if you wish to continue using easy breadcrumb and the Cambridge theme.
2 parents e2d15d0 + d5a5300 commit 29491c4

File tree

3 files changed

+66
-42
lines changed

3 files changed

+66
-42
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ Changelog
33

44
Note: the theme contains the University's house style assets (CSS, images, JavaScript). For the sake of completeness, all updates to these are also listed below.
55

6+
7.x-1.8
7+
8+
* Updated the theme to take into account the changes in the latest version of Easy Breadcrumb module 7.x-2.13. Their theme layer has changed completely and we have had to match the changes to allow us to continue to use easy breadcrumb in some Cambridge sites. If you are using easy breadcrumb prior to 7.x-2.13 you will need to upgrade to this version of the module if you wish to continue using easy breadcrumb and the Cambridge theme.
9+
10+
7.x-1.7
11+
12+
* Updated code comments.
13+
614
7.x-1.6
715

816
* Updated code comments.

template.php

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ function cambridge_theme_theme($existing, $type, $theme, $path) {
4242
'render element' => 'element',
4343
),
4444
'cambridge_easy_breadcrumb' => array(
45-
'function' => 'theme_cambridge_easy_breadcrumb',
4645
'variables' => array(
4746
'breadcrumb' => NULL,
4847
'segments_quantity' => NULL,
4948
'separator' => NULL,
50-
),
49+
),
50+
'template' => 'easy-breadcrumb',
51+
'path' => drupal_get_path('theme', 'cambridge_theme') . '/templates',
5152
),
53+
5254
);
5355
}
5456

@@ -673,6 +675,7 @@ function cambridge_theme_block_view_alter(&$data, $block) {
673675
$data['content']['#content']['#below']['navigation']['#below'][$key]['#below']['#theme_wrappers'] = array(array('cambridge_theme_left_navigation_children'));
674676
}
675677
}
678+
676679
}
677680

678681
/**
@@ -1239,57 +1242,61 @@ function cambridge_theme_breadcrumb($breadcrumbs) {
12391242
return $html;
12401243
}
12411244

1242-
/**
1243-
* Implements hook_block_view_MODULE_DELTA_alter() for the Easy Breadcrumb module's Easy Breadcrumb block.
1244-
*/
1245-
function cambridge_theme_block_view_easy_breadcrumb_easy_breadcrumb_alter(&$data, $block) {
1246-
$data['content']['easy_breadcrumb']['#theme'] = 'cambridge_easy_breadcrumb';
1247-
}
12481245

1249-
/**
1250-
* Style the Easy Breadcrumb module's Easy Breadcrumb block.
1246+
/*
1247+
* Implementation of a preprocess hook for easy breadcrumb module.
1248+
* When easy breadcrumb changed from version 2.12 to 2.13, they changed the
1249+
* module worked from a theme function to a tpl file and preprocess function.
1250+
* We have had to adapt our theme to match their new setup.
1251+
*
1252+
* This function has replaced the theme easy breadcrumb function in the
1253+
* earlier versions of the theme.
1254+
* JAG212 - 26th July 2017.
12511255
*/
1252-
function theme_cambridge_easy_breadcrumb($variables) {
1253-
$breadcrumbs = $variables['breadcrumb'];
1254-
$segments_quantity = $variables['segments_quantity'];
1255-
1256-
if (count($breadcrumbs) <= 1) {
1257-
return '';
1258-
}
1256+
function cambridge_preprocess_easy_breadcrumb(&$variables) {
1257+
$breadcrumbs = _easy_breadcrumb_build_items();
1258+
if (module_exists('schemaorg')) {
1259+
$variables['list_type'] = 'https://schema.org/BreadcrumbList';
1260+
}
1261+
else {
1262+
$variables['list_type'] = 'http://data-vocabulary.org/Breadcrumb';
1263+
}
12591264

1260-
$html = '';
1265+
// Loop round all breadcrumbs
1266+
foreach ($breadcrumbs as $i => $breadcrumb) {
1267+
$content = decode_entities($breadcrumb['content']);
12611268

1262-
if ($segments_quantity > 0) {
1263-
$html .= '<div class="campl-breadcrumb" id="breadcrumb">';
1264-
$html .= '<ul class="campl-unstyled-list campl-horizontal-navigation clearfix">';
1269+
if ($i == 0) {
1270+
$list_html = '<li class="first-child">';
1271+
}
1272+
else {
1273+
$list_html = '<li>';
1274+
}
12651275

1266-
foreach ($breadcrumbs as $i => $breadcrumb) {
1267-
if (isset($breadcrumb['url'])) {
1268-
$content = $breadcrumb['content'];
1269-
$class = $breadcrumb['class'];
1270-
$url = $breadcrumb['url'];
1271-
if (in_array('easy-breadcrumb_segment-front', $class)) {
1272-
$class[] = 'campl-home ir';
1276+
if (in_array('easy-breadcrumb_segment-front', $breadcrumb['class'])) {
1277+
// Set appropriate styling to allow home breadcrumb to appear
1278+
// as a house image rather than the word home
1279+
$breadcrumb['class'][] = 'campl-home ir';
12731280
}
1274-
if ($i == 0) {
1275-
$html .= '<li class="first-child">';
1281+
1282+
if (isset($breadcrumb['url'])) {
1283+
$variables['breadcrumb'][$i] = $list_html . '<span itemprop="title">';
1284+
$variables['breadcrumb'][$i] .= l($content, $breadcrumb['url'], array(
1285+
'attributes' => array('class' => $breadcrumb['class'])
1286+
));
1287+
$variables['breadcrumb'][$i] .= '</span></li>';
12761288
}
12771289
else {
1278-
$html .= '<li>';
1290+
// Last breadcrumb is plain text not a hyperlink
1291+
$class = implode(' ', $breadcrumb['class']);
1292+
$variables['breadcrumb'][$i] = $list_html . '<span class="' . $class . '" itemprop="title">' . check_plain($content) . '</span></li>';
12791293
}
1280-
$html .= l($content, $url, array('attributes' => array('class' => $class))) . '</li>';
1281-
}
1282-
else {
1283-
$content = html_entity_decode($breadcrumb['content']);
1284-
$class = implode(' ', $breadcrumb['class']);
1285-
$html .= '<li class="' . $class . '">' . $content . '</li>';
1286-
}
12871294
}
1288-
$html .= '</ul>';
1289-
$html .= '</div>';
1290-
}
12911295

1292-
return $html;
1296+
/* Segmentation handled by <li> styling background so we don't need this. */
1297+
//$variables['segments_quantity'] = count($variables['breadcrumb']);
1298+
//$variables['seperator_ending'] = variable_get(EasyBreadcrumbConstants::DB_VAR_SEPERATOR_ENDING, FALSE) ? 0 : 1;
1299+
//$variables['separator'] = filter_xss(variable_get(EasyBreadcrumbConstants::DB_VAR_SEGMENTS_SEPARATOR, '>>'));
12931300
}
12941301

12951302
/**

templates/easy-breadcrumb.tpl.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php if ($segments_quantity > 0): ?>
2+
<div itemscope class="easy-breadcrumb campl-breadcrumb" id="breadcrumb" itemtype="<?php print $list_type; ?>">
3+
<ul class="campl-unstyled-list campl-horizontal-navigation clearfix">
4+
<?php foreach ($breadcrumb as $i => $item): ?>
5+
<?php print $item; ?>
6+
<?php endforeach; ?>
7+
</ul>
8+
</div>
9+
<?php endif; ?>

0 commit comments

Comments
 (0)