Skip to content

Commit

Permalink
Issue #515: Add message to search results re 'more records if logged …
Browse files Browse the repository at this point in the history
…in'.
  • Loading branch information
danhgov committed Feb 5, 2025
1 parent 74f730a commit 6c9bfd1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions config/sync/views.view.site_search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2543,6 +2543,17 @@ display:
plugin_id: result
empty: false
content: '<p class="fst-italic">Displaying @start - @end of @total results.</p>'
area_text_custom:
id: area_text_custom
table: views
field: area_text_custom
relationship: none
group_type: group
admin_label: 'Message about "more search results are available if you log in".'
plugin_id: text_custom
empty: true
content: "<p>[global:bc_dc_more_results_if_logged_in]</p>\r\n"
tokenize: true
footer: { }
display_extenders: { }
cache_metadata:
Expand Down
11 changes: 11 additions & 0 deletions html/modules/custom/bc_dc/bc_dc.tokens.inc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ function bc_dc_token_info() {
'description' => t('Returns the current plus the child terms for a uuid concatentated with +.'),
];

$tokens['global']['bc_dc_more_results_if_logged_in'] = [
'name' => t('Message: Log in for more search results'),
'description' => t("Provides a message only for anonymous users, letting them know that they'll see more search results if they log in."),
];

return ['types' => $types, 'tokens' => $tokens];
}

Expand Down Expand Up @@ -80,6 +85,12 @@ function bc_dc_tokens($type, $tokens, array $data, array $options, BubbleableMet
$replacements[$original] = implode('+', $results);
}
break;

case 'bc_dc_more_results_if_logged_in':
$replacements[$original] = \Drupal::currentUser()->isAuthenticated()
? ''
: 'To access to more records based on your credentials, please consider logging in.';
break;
}
}
}
Expand Down

0 comments on commit 6c9bfd1

Please sign in to comment.