Questions tagged [8]

Version tag to tag issues specifically related to Drupal 8.x. Please note that version tags should be used only for questions that apply to a version only, not to merely say what version a site is using.

3,957 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8
votes
2answers
3k views

What is the equivalent of hook_translated_menu_link_alter() to Alter a menu link?

I want to alter the menu link in Drupal 8. In Drupal 7 we can achieve this using hook_translated_menu_link_alter function module_translated_menu_link_alter(&$item, $map) { global $user; if (!...
7
votes
1answer
1k views

How do I enable and use a view mode for a product type?

In default commerce2 (drupal 8) I want to add second product-type view mode, to show in views - like teaser version, including add-to-cart btn with variations. I have additional field in Product type ...
7
votes
1answer
768 views

With search_api_solr, how can I apply an significant field based boost when using solr 6.x?

I am using the solr backend for search_api on a drupal 8 site. I have added the value of a taxonomy term reference field (field_promoted_search) to the index. If an item of content has ...
6
votes
0answers
904 views

Custom view sorting plugin / handler

I am trying to create a custom sorting option for view that will sort result on the basis of percentage of 2 fields. field 1 = node__field_funding_amount field 2 = node__field_funding_goal and i am ...
6
votes
2answers
398 views

Big pipe and behaviors context

I have problem with drupal behaviors and context in combination with big pipe. It seems like context variable sometimes contains same part of page. I have tried: (function ($, Drupal) { Drupal....
6
votes
1answer
271 views

Is it possible to migrate data into multiple translations of entities?

I'm running a multilingual migration of events (which are stored as nodes) that have keywords on them where there are keywords (stored as terms). The keywords should be stored in a multilingual tags ...
6
votes
2answers
3k views

How to set required POST parameters for routes

With GET method we can do something like this example.user path: 'example/{user}' defaults: _controller: '\Drupal\example\Controller\ExampleController::content' requirements: ...
6
votes
0answers
1k views

How do I translate theme settings?

How do you translate custom theme settings in Drupal 8? I use hook_form_system_theme_settings_alter to add custom settings to a theme. One setting is the text string (e.g. 'Menu') to display beside ...
5
votes
0answers
860 views

How do I theme a modal popup?

How can I style Drupal 8 modal window to achieve Instagram style and behaviour? I'm creating modal through extending ControllerBase class, thus have full control of content. However I can't figure it ...
5
votes
2answers
331 views

Managing custom aliases on translated content

We have a Drupal 8 site with translated content, and using the Pathauto module. The issue we are running into is that when we un-check the "Generate automatic URL alias" on, say, the Chinese node, ...
5
votes
1answer
1k views

Configuration changes that will not import?

I have some configuration that will not import. If I run drush config-import --preview I see the changes to be imported; I hit 'y' to import. When I run the same command, the changes are still there? ...
5
votes
0answers
489 views

How do I make an archived-dump of my site?

I have multiple versions of drush and cannot make an archive-dump of my site. drush8 ard/drush8 archive-dump returns [error] The drush command 'ard' (and/or 'archive-dump') could not be found. ...
5
votes
1answer
790 views

Change views exposed filter format

I am build a JSON export using a View in Drupal 8. Problem is that the parameters for retrieving the json doesn't seem to work as I would want. In my View I need use two exposed filter criteria to ...
5
votes
1answer
2k views

Creating date field with only month and year

We are using the form API in a custom module (and not an entity field), how can we easily set the date widget for just year and month data entry. I've tried adding a #date_format attribute but no ...
5
votes
3answers
2k views

How do I define a computed field equal to the concatenation of two fields of my custom entity?

I have a custom entity (Person) with these fields: ID, nom, prenom, telephoneportable, estactive, userID, created, changed. I created it with baseFieldDefinitions. I want to have a computed field ...
5
votes
1answer
7k views

How to create a “read more” button using AJAX in a module?

I'm working on a really simple module in Drupal 8 to get the hang of things. What it does (or rather, what the page I'm asking about in this question does) is grab some data of a bunch of simple ...
5
votes
1answer
146 views

Update core keeping other composer packages

After upgrading Drupal to the last version with Drush (8.1.15) the other composer.json dependencies (e.g. drupalconsole) are removed. Are there any way to update Drupal with Drush keeping other ...
5
votes
1answer
3k views

Clear only CSS/JavaScript cache when files are aggregated

When aggregating CSS/JavaScript files using performance page in Drupal 8, drush cc css-js doesn't work, and I've to clear/rebuild all cache. Is this a bug or the normal behavior? How do I properly ...
4
votes
0answers
666 views

Custom views filter for custom view field

I want to created a custom views field, following this tutorial: https://www.webomelette.com/creating-custom-views-field-drupal-8. This custom field counts and returns the number of referencing ...
4
votes
0answers
227 views

How to use Context with Views' Contextual Filters

I have content type City. I have a view page with contextual filters to show the cities at the URL pattern locations/<city id>. I want to use Context to add blocks to these cities pages but I ...
4
votes
0answers
230 views

What is the way to restrict access to a store and its products by user?

I'm using Commerce 2 and I have: User A and User B Store X assigned to User A (by entity reference) Store Y assigned to User B I would like to restrict access to products of stores so that User A ...
4
votes
0answers
317 views

Image styles are not generated in Docker for Windows

When I open in browser http://localhost:1567/sites/default/files/styles/thumbnail/public/2017-10/478069720_1384178114_4.jpg, I see 404. The "original" images are uploaded successfully, and the ...
4
votes
0answers
2k views

How to setup Swift Mailer to send mails using SMTP server and TLS encryption?

I'm trying to send Drupal 8 emails using Swift Mailer (5.4.8, 8.x-1.0-beta1) and a remote SMTP server. The transport should be encrypted, so TLS should be used. This is my setting: Unfortunatly when ...
4
votes
0answers
1k views

Add Expression for Entity Query

I've been working with the entityQuery to query the db and get an array of filtered nids however I need to add an expression to my query. I've checked the Query class and found a protected sqlQuery ...
4
votes
1answer
82 views

Benefit of config entities over regular config entries?

In Drupal 8 it is possible to store configuration in "config entities". However, the same can also be achieved with non-entity config entries. E.g. one example for a config entity schema, from core....
4
votes
0answers
350 views

Front page without language prefix

I have a multilingual site on Drupal 8 migrated from Drupal 7. It has URL language detection method. Default language is English, it has path prefix /en. With this configuration front page is ...
4
votes
1answer
1k views

Adding elements to a field widget

What I need to accomplish is adding a link to a node to field widgets (the node contains the formatted instructions to properly compile the field). The goal is something like this: "What is this?" is ...
4
votes
1answer
3k views

“message”: “X-CSRF-Token request header is missing”

When using postman to fire post request I get this message. Does anyone has idea how to disable it? In this case it is post to register user so no authentification is required.
4
votes
1answer
665 views

How do I remove JOIN in hook_views_query_alter()?

I have a view with two filters (A + B). Filter B should only be included in the query, if a specific value in filter A is set (like a "conditional filter"). So I tried to remove the where condition ...
4
votes
1answer
1k views

Ajax pager with form callback

I created a form using the form api that outputs a list of results via an ajax callback. I want the said view to paginated. How can i do that? I'm using drupal 8 and don't want to use embeded views.
4
votes
2answers
810 views

Send mail notification when node of given type gets created

Use case: a small site where I want to warn all users by mail whenever a new content of a particular type is created. I thought I would try Rules+Actions to handle this. I'm working on a vanilla ...
4
votes
0answers
974 views

How to create a Draft view with Content Moderation?

In Drupal 7 with Workbench Moderation is easy to create a view to show the last Draft of a content: You have a relation in the view named Workbench Moderation: Node, so using the filter Workbench ...
4
votes
1answer
83 views

Why is my functional test not matching my manual testing?

I have a Drupal 8 module for banning users based on country. In it, I have the following test. public function setUp() { parent::setUp(); $this->drupalLogin($this->adminSitesUser); } ...
4
votes
1answer
646 views

Action links available options / caching

I have some action links defined in module.links.actions.yml which uses a custom "create entity" route. For entity creation I set up some restrictions and at some point the access is denied. The ...
4
votes
1answer
886 views

When I POST an image file via rest, response is 201: Object Moved, status is temporary

I'm attempting to POST images to Drupal 8 via the REST api. The creation is successful (201) and the images appear in the files list. However, there are problems. I'm not sure if they are ...
4
votes
0answers
1k views

Loading a form in dialog/modal returns an error

I have a form with a submit button binded to an AJAX callback that opens up a modal with another AJAX form. The modal dialog opens with the form, but the AJAX submit in that modal form isn't ...
4
votes
0answers
175 views

How to remove form validation in D8 under certain conditions?

I'm trying to save a node as a draft, but only if we are saving as a draft (Workbench Moderation). Otherwise, validation should be run as normal. The user must be allowed to save a node in any state,...
4
votes
0answers
1k views

How do I index custom fields with the search API using elasticsearch?

I see all kinds of tutorials to get apache to index content. Is there any difference in getting elasticsearch to index my new custom field? On the field page I can see my field but when i expand it ...
4
votes
0answers
331 views

Execute form custom validator first before default validation

I have added a custom form validation on node/add page in drupal 8. The purpose of adding this validator is to add a slash before the path alias string. By default if a path alias string is added ...
4
votes
1answer
761 views

Prevent dual submit on form submission

I've got a form that submits via AJAX and in the callback I need to rebuild certain parts of the page to reflect the newly submitted data. One of these parts is the form, which I need to clear all ...
4
votes
2answers
1k views

How to programmatically add content to a group in the Group Module?

I'm using the Group module. If I have a group type such as Project, and I have a content type such as Article, and I programmatically created a new article node using Node::create(), how can I in the ...
4
votes
1answer
2k views

View for Taxonomy terms?

How can I output nodes which linked with taxonomy term through a view? How can I link taxonomy vocabulary with a view wich will output appropriate nodes for each term of this vocabulary? In Drupal 7 ...
4
votes
1answer
95 views

How do I store filtered markup?

As instructed, I am looking at porting Message to Drupal 8. It uses token to generate the message arguments and so they are HTML escaped. This is the current code: foreach ($matches[1] as $delta =&...
4
votes
1answer
425 views

Failure getting nodes from terms via the rest api

I have added a REST web service in Drupal and all content is tagged with taxonomy. I'm now trying to acquire all related nodes to the terms. First I'm calling taxonomy_vocabulary/getTree along with ...
4
votes
2answers
742 views

Cannot import Paragraph based Feature into new site

Perhaps someone with a bit more Features expertise can help me here. I have a Drupal site with 25 or so Paragraph types that I would like to export (one by one) to its own contained Feature. I ...
4
votes
1answer
2k views

How to rename uploaded files

Using Drupal 8, I want to rename and clean all filenames, e.g. If someone uploads file named like this Screen Shot 2016-03-29 at 1.13.21 PM.jpg, I want to clean it so that convert all spaces to dashes ...
3
votes
0answers
45 views

How to know which method is not covered by Unit test?

I want to finish the Unit test for a contrib module and I want to know if there is a way to know the methods that don't have tests, so this way, I can identify the tests I need to implement. Is there ...
3
votes
0answers
110 views

How do we programmatically place a section and then a block in that region on module install?

We are looking for the best way to export a defined/built layout with inline blocks and then use that to programmatically set both them during a module install. eg. module install create node in ...
3
votes
0answers
83 views

What is the underlying logic for generating an icon map for a custom registered layout?

There seems to be a dearth of information on the internet about how to generate an icon_map for newly registered layouts in Layout Builder. I've gotten as far as finding a patch file from the project ...
3
votes
0answers
109 views

What does it mean if expire is set to null in a cache table?

I am looking at the documentation for the expire field in the cache tables and the documentation in CacheBackendInterface.php says: * @param int $expire * One of the following values: * - ...