Skip to content

Commit dbe8c00

Browse files
authored
Merge pull request #17 from dof-dss/development
Unity modules release 1.0.7
2 parents 6227b1c + 264f296 commit dbe8c00

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

unity_search_pages/unity_search_pages.module

+11-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use Solarium\Core\Query\QueryInterface;
99
use Drupal\search_api\Query\QueryInterface as SearchApiQueryInterface;
1010
use Drupal\Core\Language\Language;
1111
use Drupal\Component\Utility\Html;
12+
use \Drupal\Core\StringTranslation\TranslatableMarkup;
1213

1314
/**
1415
* Implements hook_preprocess_views_view() for views_view.
@@ -162,12 +163,19 @@ function unity_search_pages_preprocess_block(&$variables) {
162163
*/
163164
function unity_search_pages_preprocess_page_title(&$variables) {
164165
$current_route = \Drupal::routeMatch()->getRouteName();
165-
$title = $variables['title'];
166+
$title_raw = $variables['title'];
166167
$pattern = '/view.\w*search.\w*search_page/';
167168

168169
if (preg_match($pattern, $current_route)) {
169-
if (preg_match('/\w*\b\s- search results/', $title)) {
170-
$new_title = strtok($title, ' -');
170+
if ($title_raw instanceof TranslatableMarkup) {
171+
$title_text = $title_raw->render();
172+
} elseif (is_array($title_raw) && isset($title_raw['#markup'])) {
173+
$title_text = $title_raw['#markup'];
174+
} else {
175+
$title_text = $title_raw;
176+
}
177+
if (preg_match('/\w*\b\s- search results/', $title_text)) {
178+
$new_title = strtok($title_text, ' -');
171179
$variables['title'] = t($new_title);
172180
$variables['title_subtitle'] = t('search results');
173181
}

0 commit comments

Comments
 (0)