Questions tagged [8]

Version tags should be used for questions that apply to a version only, not to merely say what version a site is using.

4,085 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
14 votes
0 answers
2k 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 ...
Peacog's user avatar
  • 528
12 votes
0 answers
1k 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 ...
autopoietic's user avatar
  • 1,662
10 votes
1 answer
1k 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 ...
Jonas's user avatar
  • 101
9 votes
0 answers
3k 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 ...
Joost's user avatar
  • 1,218
8 votes
1 answer
2k 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 ...
113408's user avatar
  • 326
8 votes
2 answers
733 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, ...
aburke626's user avatar
  • 371
8 votes
2 answers
2k 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? ...
dbj44's user avatar
  • 4,724
8 votes
2 answers
4k views

Migrate address field

I am currently searching for a example to migrate data into an address field in Drupal 8 without any luck for now. Has someone a hint for me on how to map the fields? I tried the following: my....
Sebastian's user avatar
  • 635
7 votes
0 answers
527 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 ...
Umed Godd's user avatar
  • 317
7 votes
1 answer
166 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 ...
jorgetutor's user avatar
  • 2,115
6 votes
0 answers
284 views

How to get referencing parent entity when adding entities via Inline Entity Form to set automatic titles?

I have a content type "Parent" and a content type "Child". When adding Parents, the user can add Childs via Inline Entity Form. Child content types have Automatic Entity Label enabled. In that ...
Alex's user avatar
  • 2,493
6 votes
0 answers
606 views

How can I convert an existing image field into a Media image reference field?

I have an image field that I created before Drupal 8.5, when media was introduced in the ui. The field already contains content and I would like to make use of the reusable media functionality that is ...
Pekens Antoine's user avatar
6 votes
1 answer
158 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....
donquixote's user avatar
  • 3,590
6 votes
0 answers
1k 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 ...
Adrian Cid Almaguer's user avatar
6 votes
3 answers
3k 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 ...
gbmapo's user avatar
  • 1,022
5 votes
0 answers
496 views

How to add translation to Inline Entity Form + Entity Browser

Situation I've got a special "Dashboard" node that consists of entity references to other node types. In dashboard form mode all widgets are configured to use Entity Browser to display an (Inline ...
Hudri's user avatar
  • 5,242
5 votes
1 answer
865 views

Invalidating render cache items for anonymous?

We have a certain content type in Drupal 8 that has a small grid of data on it that is populated from an API call when the node view is being built. In that call, I am checking for cache and setting ...
Kevin's user avatar
  • 27.5k
5 votes
2 answers
3k views

How to pass a field value as contextual filter argument using Twig Tweak drupal_view?

In Drupal 8, I'm using Twig Tweak to embed a view. I have a contextual filter set to one of the node's fields, field_project_id. If I use a literal for the third argument, it works. If I try to ...
timwilson's user avatar
5 votes
0 answers
1k views

Workflow, Workflows, Workspace, and State Machine-- what is the difference?

Drupal 8 core has an experimental module called Workflows. There is also a contrib moduled called Workflow. There's also the Workspace module, which is associated with the Deploy module. Commerce 2 ...
Patrick Kenny's user avatar
5 votes
1 answer
402 views

Migration of content with an UI

My goal is to import data of customers from a csv file to my custom entity. For that I wrote a migration with the migrate_source_csv module as source plugin. This works fine, but the problem is, that ...
Chris4783's user avatar
  • 968
4 votes
0 answers
386 views

Configuration export via drush randomly change the value of labels\other content in multilanguage sites

I've a multilanguage site, with Italian set as default and English as secondary language. When exporting the configuration via drush - drush cex command - sometimes the labels of other kind of content ...
Giuseppe's user avatar
  • 835
4 votes
0 answers
223 views

Which is a better practice in Drupal 8 to get field value from an entity?

I have a product variation entity from which I need to retrieve SKU value. I am able to get the value from the below lines, but I want to know which is a better practice and why. $entity->getSKU();...
Vishnu Vijaykumar's user avatar
4 votes
1 answer
1k views

How to implement StackMiddleware for a redirection correctly?

I'm working on a redirection (for unauthenticated users) for my Drupal 8 site. Currently, the redirection works however, the redirection persists even after user is authenticated. I found this article ...
Joe Spinelli's user avatar
4 votes
0 answers
1k views

How do I conditionally change the value of a field depending on the value chosen in another?

This was so easy in webform 4.x. However, I cannot seem to find it in webform 5.x. I am creating a form using webform 5.1, and I need to set the value of the fees for a particular grade for an ...
Jasper Levi's user avatar
4 votes
0 answers
93 views

Register an object with the Service Container and give it a setRequest() (get base url)

I'm looking for a way to get the hostname of a multisite, and I've found several answers about it. One of the solutions was to use: Answer link $host= \Drupal::request()->getHost();   or \...
chalo's user avatar
  • 421
4 votes
0 answers
1k views

How to add 'Set-cookie' header on rest POST response

I have subdomain front.test.local as frontend ngx-app and another subdomain back.test.local for the backend pure Drupal both on https - cookie-domain is set to '.test.local'. I need cookie because ...
svetlio's user avatar
  • 1,484
4 votes
1 answer
709 views

How to get attachments out of a twig file

How do I get the attachments out a twig file and add them to a build array? If there is a twig file with {{ attach_library('mytheme/pullquote') }} And because it's in an ajax response, I need to ...
oknate's user avatar
  • 14.1k
4 votes
0 answers
2k views

Difference between service and plugin?

After have read some link i'm still confused about the difference between service and plugin. I am not speaking about plugin like block or Field formater etc... i would like to take an example : I ...
Kevin's user avatar
  • 2,528
4 votes
0 answers
283 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 ...
Jeff's user avatar
  • 283
4 votes
0 answers
440 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 ...
Sinan Erdem's user avatar
4 votes
0 answers
452 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 ...
milkovsky's user avatar
  • 5,279
4 votes
0 answers
3k 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 ...
Philipp Michael's user avatar
4 votes
0 answers
187 views

Can't make sense of the CSS loading order

I want bootstrap.css to load first, because it's breaking all of my styles. Yet, no matter what settings I use in my module, it always loads last. Every CSS file from a library in my theme loads ...
RaisinBranCrunch's user avatar
4 votes
0 answers
522 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 ...
kovtunos's user avatar
4 votes
0 answers
3k views

"DISTINCT" in Views not applying?

I am trying to add DISTINCT to a view, and for example I chose the default content view. I expect that it would add DISTINCT(id), but the query does not change at all. Why is it not added? Update: ...
Kevin's user avatar
  • 27.5k
4 votes
0 answers
421 views

Migrate taxonomy with depth

I need to migrate a CSV file of 3000 Taxonomy terms with depth of 5 levels deep. This is a small sample of the CSV comma-separated values file. About Us About Us, Our Programs About Us, Our History, ...
paul cappucci's user avatar
4 votes
1 answer
992 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 ...
Kevin's user avatar
  • 27.5k
4 votes
0 answers
351 views

Is ContentEntityBase::access affected by hook_ENTITY_TYPE_access?

Are calls to the access() method on entity objects which is provided by ContentEntityBase affected by hook_ENTITY_TYPE_access()? I am asking because the Paragraphs module, in src/...
ummdorian's user avatar
  • 517
4 votes
0 answers
1k views

Why are the thumbnail images not loading?

I am using Drupal 8, and have just moved my site to shared hosting. When I upload a standard image field on my shared hosting environment, the thumbnail image does not show up. This works perfectly on ...
mike421's user avatar
  • 41
4 votes
1 answer
678 views

Custom views filter on computed field

I've built a custom field into the view which displays the menu name a node is assigned to, but I want to filter on the menu name. How can you filter on this computed field? The only examples I have ...
Dylan Spencer James's user avatar
4 votes
0 answers
308 views

How to hide a menu item of a view for an administrator?

I have created a view with Views and restricted the access by Role. I also created a menu with the view, and I didn't select the Administrator role to be included (so Administrator role does not have ...
usethe23's user avatar
  • 641
4 votes
2 answers
1k 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 ...
Philipp Michael's user avatar
4 votes
1 answer
98 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); } public ...
Webdrips's user avatar
  • 732
4 votes
1 answer
1k 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 ...
Marius Ilie's user avatar
  • 3,062
4 votes
1 answer
957 views

How to fix "Unable to save a field collection item without a valid reference to a host entity" error?

I programmatically created a series of custom content entities which contain field collections. My site had an execution timeout error in the middle of entity creation and saving. I can not delete ...
saramm1's user avatar
  • 727
4 votes
0 answers
388 views

How to create additional base fields for ECK entity

For example I want to create a Vehicle ECK base type and Car and Truck bundles, but I want to define fields for the Vehicle base type that would be shared between Car and Truck. In UI, by default, I'...
Trupal's user avatar
  • 513
4 votes
0 answers
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 ...
edwardchiapet's user avatar
4 votes
1 answer
2k 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 ...
BrandenB171's user avatar
  • 1,102
4 votes
1 answer
945 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 ...
Lyndon Cox's user avatar
4 votes
1 answer
3k 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 ...
otarza's user avatar
  • 944

1
2 3 4 5
82