Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
2693a335
Commit
2693a335
authored
May 23, 2013
by
Jennifer Hodgdon
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1948564
by bdgreen: Move search conditions callback sample function to right group/topic
parent
5a60cba4
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/search/search.api.php
+39
-37
39 additions, 37 deletions
core/modules/search/search.api.php
with
39 additions
and
37 deletions
core/modules/search/search.api.php
+
39
−
37
View file @
2693a335
...
...
@@ -46,43 +46,6 @@ function hook_search_info() {
);
}
/**
* Provide search query conditions.
*
* Callback for hook_search_info().
*
* This callback is invoked by search_view() to get an array of additional
* search conditions to pass to search_data(). For example, a search module
* may get additional keywords, filters, or modifiers for the search from
* the query string.
*
* This example pulls additional search keywords out of the $_REQUEST variable,
* (i.e. from the query string of the request). The conditions may also be
* generated internally - for example based on a module's settings.
*
* @param $keys
* The search keywords string.
*
* @return
* An array of additional conditions, such as filters.
*
* @ingroup search
*/
function
callback_search_conditions
(
$keys
)
{
$conditions
=
array
();
if
(
!
empty
(
$_REQUEST
[
'keys'
]))
{
$conditions
[
'keys'
]
=
$_REQUEST
[
'keys'
];
}
if
(
!
empty
(
$_REQUEST
[
'sample_search_keys'
]))
{
$conditions
[
'sample_search_keys'
]
=
$_REQUEST
[
'sample_search_keys'
];
}
if
(
$force_keys
=
config
(
'sample_search.settings'
)
->
get
(
'force_keywords'
))
{
$conditions
[
'sample_search_force_keywords'
]
=
$force_keys
;
}
return
$conditions
;
}
/**
* Define access to a custom search routine.
*
...
...
@@ -396,3 +359,42 @@ function hook_update_index() {
/**
* @} End of "addtogroup hooks".
*/
/**
* Provide search query conditions.
*
* Callback for hook_search_info().
*
* This callback is invoked by search_view() to get an array of additional
* search conditions to pass to search_data(). For example, a search module
* may get additional keywords, filters, or modifiers for the search from
* the query string.
*
* This example pulls additional search keywords out of the $_REQUEST variable,
* (i.e. from the query string of the request). The conditions may also be
* generated internally - for example based on a module's settings.
*
* @param $keys
* The search keywords string.
*
* @return
* An array of additional conditions, such as filters.
*
* @ingroup callbacks
* @ingroup search
*/
function
callback_search_conditions
(
$keys
)
{
$conditions
=
array
();
if
(
!
empty
(
$_REQUEST
[
'keys'
]))
{
$conditions
[
'keys'
]
=
$_REQUEST
[
'keys'
];
}
if
(
!
empty
(
$_REQUEST
[
'sample_search_keys'
]))
{
$conditions
[
'sample_search_keys'
]
=
$_REQUEST
[
'sample_search_keys'
];
}
if
(
$force_keys
=
config
(
'sample_search.settings'
)
->
get
(
'force_keywords'
))
{
$conditions
[
'sample_search_force_keywords'
]
=
$force_keys
;
}
return
$conditions
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment