-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfacets_hardcode.module
More file actions
35 lines (29 loc) · 1.42 KB
/
facets_hardcode.module
File metadata and controls
35 lines (29 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
function facets_hardcode_preprocess_views_pager_with_summary(&$variables) {
if (\Drupal\facets_hardcode\FacetsHardcodePathHelper::isFacetPath()) {
$faceted_path = \Drupal\facets_hardcode\FacetsHardcodePathHelper::getFacetedPath();
$base_path = \Drupal\facets_hardcode\FacetsHardcodePathHelper::filterFacetsFromPath($faceted_path);
if ($faceted_path != $base_path) {
if (isset($variables['items']['pages'])) {
foreach ($variables['items']['pages'] as $index => $page) {
$variables['items']['pages'][$index]['href'] = str_replace($base_path, $faceted_path, $page['href']);
}
}
foreach (['next', 'last', 'first', 'previous'] as $key) {
if (isset($variables['items'][$key])) {
$variables['items'][$key]['href'] = str_replace($base_path, $faceted_path, $variables['items'][$key]['href']);
}
}
}
}
}
/**
* Implements hook_entity_view_alter().
*/
function facets_hardcode_entity_view_alter(array &$build, Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
\Drupal\facets_hardcode\FacetsHardcodeMetatagHelper::updateCanonicalUrls($build);
}
function facets_hardcode_preprocess_html(&$variables) {
$facet_path = \Drupal\facets_hardcode\FacetsHardcodePathHelper::getFacetedPath();
\Drupal\facets_hardcode\FacetsHardcodeMetatagHelper::setRobotsMetatag($variables['page'], $facet_path);
}