Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
facets-3490556
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
facets-3490556
Commits
fe311204
Commit
fe311204
authored
7 years ago
by
Joris Vercammen
Committed by
Joris Vercammen
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2827808
by borisson_: Facets on multilangual site
parent
9064a63c
Branches
8.x-1.x
Branches containing commit
Tags
8.x-1.1
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.txt
+7
-0
7 additions, 0 deletions
README.txt
tests/src/Functional/LanguageIntegrationTest.php
+51
-0
51 additions, 0 deletions
tests/src/Functional/LanguageIntegrationTest.php
with
58 additions
and
0 deletions
README.txt
+
7
−
0
View file @
fe311204
...
...
@@ -146,3 +146,10 @@ the chosen module (and others, probably) doesn't find the select element.
So the library should be attached to the block in custom code, we haven't done
this in facets because we don't want to support all possible frameworks.
See https://www.drupal.org/node/2853121 for more information.
Q: Why are facets results links from another language showing in the facet
results?
A: Facets use the same limitations as the query object passed, so when using
views, add a filter to the view to limit to one language.
Otherwise, this is solved by adding a `hook_search_api_query_alter()` that
limits the results to the current language.
This diff is collapsed.
Click to expand it.
tests/src/Functional/LanguageIntegrationTest.php
+
51
−
0
View file @
fe311204
...
...
@@ -151,6 +151,57 @@ class LanguageIntegrationTest extends FacetsTestBase {
$this
->
clickLink
(
'item'
);
$this
->
assertTrue
(
strpos
(
$this
->
getUrl
(),
'xx-lolspeak/'
),
'Found the language code in the url'
);
$this
->
assertTrue
(
strpos
(
$this
->
getUrl
(),
'tyto_alba'
),
'Found the facet in the url'
);
}
/**
* Tests facets where the count is different per language.
*
* @see https://www.drupal.org/node/2827808
*/
public
function
testLanguageDifferences
()
{
$entity_test_storage
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
'entity_test_mulrev_changed'
);
$entity_test_storage
->
create
([
'name'
=>
'foo bar baz'
,
'body'
=>
'test test'
,
'type'
=>
'item'
,
'keywords'
=>
[
'orange'
,
'lol'
],
'category'
=>
'item_category'
,
'langcode'
=>
'xx-lolspeak'
,
])
->
save
();
$entity_test_storage
->
create
([
'name'
=>
'foo bar baz'
,
'body'
=>
'test test'
,
'type'
=>
'item'
,
'keywords'
=>
[
'orange'
,
'rofl'
],
'category'
=>
'item_category'
,
'langcode'
=>
'xx-lolspeak'
,
])
->
save
();
$id
=
'water_bear'
;
$this
->
createFacet
(
'Water bear'
,
$id
,
'keywords'
);
$this
->
drupalGet
(
'admin/config/search/search-api/index/'
.
$this
->
indexId
.
'/edit'
);
$this
->
assertEquals
(
2
,
$this
->
indexItems
(
$this
->
indexId
),
'2 items were indexed.'
);
$this
->
drupalGet
(
'search-api-test-fulltext'
);
$this
->
assertFacetBlocksAppear
();
$this
->
assertSession
()
->
pageTextContains
(
'orange'
);
$this
->
assertSession
()
->
pageTextContains
(
'grape'
);
$this
->
assertSession
()
->
pageTextContains
(
'rofl'
);
$this
->
drupalPostForm
(
NULL
,
[
'language'
=>
'xx-lolspeak'
],
'Search'
);
$this
->
assertFacetBlocksAppear
();
$this
->
assertSession
()
->
pageTextContains
(
'orange'
);
$this
->
assertSession
()
->
pageTextContains
(
'rofl'
);
$this
->
assertSession
()
->
pageTextNotContains
(
'grape'
);
$this
->
drupalPostForm
(
NULL
,
[
'language'
=>
'en'
],
'Search'
);
$this
->
assertFacetBlocksAppear
();
$this
->
assertSession
()
->
pageTextContains
(
'orange'
);
$this
->
assertSession
()
->
pageTextContains
(
'grape'
);
$this
->
assertSession
()
->
pageTextNotContains
(
'rofl'
);
}
}
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