Skip to content

Commit

Permalink
Merge pull request #97 from misd-service-development/7.x-1.8
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JeebsUK authored Jul 28, 2017
2 parents e2d15d0 + d5a5300 commit 29491c4
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 42 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Changelog

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.

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.

7.x-1.7

* Updated code comments.

7.x-1.6

* Updated code comments.
Expand Down
91 changes: 49 additions & 42 deletions template.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ function cambridge_theme_theme($existing, $type, $theme, $path) {
'render element' => 'element',
),
'cambridge_easy_breadcrumb' => array(
'function' => 'theme_cambridge_easy_breadcrumb',
'variables' => array(
'breadcrumb' => NULL,
'segments_quantity' => NULL,
'separator' => NULL,
),
),
'template' => 'easy-breadcrumb',
'path' => drupal_get_path('theme', 'cambridge_theme') . '/templates',
),

);
}

Expand Down Expand Up @@ -673,6 +675,7 @@ function cambridge_theme_block_view_alter(&$data, $block) {
$data['content']['#content']['#below']['navigation']['#below'][$key]['#below']['#theme_wrappers'] = array(array('cambridge_theme_left_navigation_children'));
}
}

}

/**
Expand Down Expand Up @@ -1239,57 +1242,61 @@ function cambridge_theme_breadcrumb($breadcrumbs) {
return $html;
}

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

/**
* Style the Easy Breadcrumb module's Easy Breadcrumb block.
/*
* Implementation of a preprocess hook for easy breadcrumb module.
* When easy breadcrumb changed from version 2.12 to 2.13, they changed the
* module worked from a theme function to a tpl file and preprocess function.
* We have had to adapt our theme to match their new setup.
*
* This function has replaced the theme easy breadcrumb function in the
* earlier versions of the theme.
* JAG212 - 26th July 2017.
*/
function theme_cambridge_easy_breadcrumb($variables) {
$breadcrumbs = $variables['breadcrumb'];
$segments_quantity = $variables['segments_quantity'];

if (count($breadcrumbs) <= 1) {
return '';
}
function cambridge_preprocess_easy_breadcrumb(&$variables) {
$breadcrumbs = _easy_breadcrumb_build_items();
if (module_exists('schemaorg')) {
$variables['list_type'] = 'https://schema.org/BreadcrumbList';
}
else {
$variables['list_type'] = 'http://data-vocabulary.org/Breadcrumb';
}

$html = '';
// Loop round all breadcrumbs
foreach ($breadcrumbs as $i => $breadcrumb) {
$content = decode_entities($breadcrumb['content']);

if ($segments_quantity > 0) {
$html .= '<div class="campl-breadcrumb" id="breadcrumb">';
$html .= '<ul class="campl-unstyled-list campl-horizontal-navigation clearfix">';
if ($i == 0) {
$list_html = '<li class="first-child">';
}
else {
$list_html = '<li>';
}

foreach ($breadcrumbs as $i => $breadcrumb) {
if (isset($breadcrumb['url'])) {
$content = $breadcrumb['content'];
$class = $breadcrumb['class'];
$url = $breadcrumb['url'];
if (in_array('easy-breadcrumb_segment-front', $class)) {
$class[] = 'campl-home ir';
if (in_array('easy-breadcrumb_segment-front', $breadcrumb['class'])) {
// Set appropriate styling to allow home breadcrumb to appear
// as a house image rather than the word home
$breadcrumb['class'][] = 'campl-home ir';
}
if ($i == 0) {
$html .= '<li class="first-child">';

if (isset($breadcrumb['url'])) {
$variables['breadcrumb'][$i] = $list_html . '<span itemprop="title">';
$variables['breadcrumb'][$i] .= l($content, $breadcrumb['url'], array(
'attributes' => array('class' => $breadcrumb['class'])
));
$variables['breadcrumb'][$i] .= '</span></li>';
}
else {
$html .= '<li>';
// Last breadcrumb is plain text not a hyperlink
$class = implode(' ', $breadcrumb['class']);
$variables['breadcrumb'][$i] = $list_html . '<span class="' . $class . '" itemprop="title">' . check_plain($content) . '</span></li>';
}
$html .= l($content, $url, array('attributes' => array('class' => $class))) . '</li>';
}
else {
$content = html_entity_decode($breadcrumb['content']);
$class = implode(' ', $breadcrumb['class']);
$html .= '<li class="' . $class . '">' . $content . '</li>';
}
}
$html .= '</ul>';
$html .= '</div>';
}

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

/**
Expand Down
9 changes: 9 additions & 0 deletions templates/easy-breadcrumb.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php if ($segments_quantity > 0): ?>
<div itemscope class="easy-breadcrumb campl-breadcrumb" id="breadcrumb" itemtype="<?php print $list_type; ?>">
<ul class="campl-unstyled-list campl-horizontal-navigation clearfix">
<?php foreach ($breadcrumb as $i => $item): ?>
<?php print $item; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>

0 comments on commit 29491c4

Please sign in to comment.