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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
1k views

How to get access all images of custom directory in twig template?

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use file_scan_directory and drupal_get_path in below codes to get any non static images path ...
1 vote
2 answers
1k views

Redirect to 404 page, if the path alias doesn't exist

I am developing a multilingual site in Drupal 8. I added content in Turkish and I didn't create any translation for that node. I managed to redirect user to the path alias. For example, when users ...
1 vote
1 answer
423 views

Geocoder and KML files

I am using Drupal 8 and I am trying to display a map of a Geofield field, using Leaflet. This part works as expected when I manually enter coordinates into the Geofield. But problem comes with the ...
0 votes
1 answer
1k views

Update entity properties fetched with entityTypeManager()->getStorage

I am loading all entity types I need to update like below $current_fruit = \Drupal::entityTypeManager()->getStorage('fruit')->loadByProperties(['status' => '1']); Then I update them in a ...
0 votes
2 answers
2k views

How can I get translation for a field of custom date

I am using the paragraphs module. I have a field which contains a date and time e.g. for events, which is added by an author. For the output I use a paragraph-twig-file and I have this: <div class=...
2 votes
1 answer
1k views

form_alter and #element_validate inside .module file

Inside my .module file, I have created a hook for alter register_form and add a password field with a custom field-validation: function xenforo_form_user_register_form_alter(&$form, \Drupal\Core\...
1 vote
3 answers
4k views

How do I add 2 blocks side-by-side in Bootstrap theme's "Content" region?

I have block views on the first page in the "Content" region of the Bootstrap theme that I would like to display as follows: _________________ | | | another block | |...
0 votes
1 answer
611 views

Theming paragraph fields from entity reference in view

I have a view (Drupal 8) where I load my entity reference field (display hidden), with three fields from a Paragraph type and a certain custom display). The HTML markup looks like this now: <div ...
1 vote
1 answer
747 views

POST JSON data denormalization error

I created rest resource plugin in a custom module and need to send some JSON data with the request, and access it in the post function. At the moment my post function does not do anything but return ...
0 votes
1 answer
493 views

How do I override /theme/custom twig in my module to render input fields?

I have a module that is building a form. I want to theme the form using twig within my module so it does not interfere with my theme/custom twigs. My buildForm function is: public function buildForm(...
0 votes
1 answer
804 views

How to filter GraphQL query by content language?

I am coding Drupal 8/Angular app and Angular is fetching data from Drupal using GraphQL. Everything works fine except now I need to query nodes in a particular language. This is my query: { ...
0 votes
1 answer
512 views

Currency switcher

Is there a currency negotiation service in Drupal Commerce 8? How can I change product currency on my multi currencies e-commerce?
1 vote
5 answers
3k views

Show menu links for anonymous users only

I need to show the user register link as a menu item in the account menu. I am able to add the link in the menu via links.menu.yml. The menu links shows up for anonymous users as well as ...
3 votes
1 answer
2k views

Why are two database tables (node and node_field_data) used for node data?

I would like to understand the database architecture of Drupal 8. I noticed that Drupal 8 has two separate tables (node and node_field_data) which include almost the same columns. Can anyone give some ...
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 ...
2 votes
4 answers
1k views

How to remove unwanted div from view rendered block?

In D8 I've created a view and assigned it into a block, I've created corresponding template for both view and block. Most of the unwanted addition of div's and classes has been removed. But the ...
1 vote
1 answer
586 views

Display Suite Fields not showing

I created a bootstrap sub theme and and have enabled display suite. I have enabled ds extra fields and chose a layout for my content type for full view display. When going to the full view page of ...
17 votes
8 answers
22k views

Unable to install ... already exist in active configuration

On Drupal 8.1 I keep running in those kind of messages when I try to activate a custom module or a custom feature that makes some modification to the basic page. (add fields). It is really annoying... ...
11 votes
3 answers
6k views

Set timestamp field default value empty

I have created field type "Timestamp" in my Drupal 8 node. Field is not required. In field settings default value, there is HTML 5 datetime picker, in which you can select default date/time or leave ...
0 votes
2 answers
979 views

How can I add "data-target" additional attribute in mega menu?

How can I add an additional attribute to menu item I am using mega menu? On element inspect my current menu url is displaying as : <a class="we-mega-menu-li activeNav" title=""href="/clients/...
0 votes
2 answers
614 views

Pay-Per-Node Functionality

My client would like a content type that has to be purchased by a registered user on a node-per-node basis. A previously registered user will see a view with the available content they can purchase ...
0 votes
1 answer
858 views

How do I get a list of all CSS and JS that are attached to a page?

In Drupal 8, how do I get all CSS and JS that is attached to a page? In Drupal 7, I could use drupal_add_css() or drupal_add_js() without arguments, to get an array containing a list of all the files/...
0 votes
1 answer
2k views

Docker website running locally not loading CSS

I'm completely new to Drupal, and I'm running this multi-container Drupal-Docker app locally, and website is only loading HTML, no CSS. These are the only error warnings I am getting. exception '...
2 votes
2 answers
677 views

Add a class the the form element (tag) of the search block form

How do I add a class to the form element of the search block form? I mean, add a class to this element: <form action="/search/node" method="get" id="search-block-form" accept-charset="UTF-8" data-...
0 votes
2 answers
616 views

How to retrieve #tree values inside a form?

I am new at Drupal 8 and I am creating a module that has a #tree form. I chose #tree form to create multiple forms which has the same textfields and button. I came across one document in drupal about #...
3 votes
2 answers
1k views

How do I get comments to be indexed?

I'm not sure if it's actually doing this; I can't see any options for comment fields in the configuration. How can I check? Does it say explicitly somewhere?
0 votes
1 answer
875 views

Trying to Conditionally Add JS File to page if in a paragraph block reference on that page

I am not sure how to accomplish this... I want to have a custom block that I have created and referenced via paragraphs to implement code in that block and push it into the header of the page. The ...
0 votes
1 answer
769 views

Getting a menu delivered via REST

I am trying to get a menu via REST and I've created a new module and rest resource plugin that allows for GET on /entity/restmenu/{menu_name}. I can successfully return this example json using this ...
0 votes
1 answer
557 views

How do I get the entity ID from a view row and pass it along to the item list template?

I have a view which returns rows of entities. Each entity has several multi-value fields. The structure is kinda like this: Field 1: Item A Item B Item C ... Item H Field 2: Item A Item B Item C ...
0 votes
1 answer
966 views

Custom Ajax forms with managed_file form element

We have a form with three fields - where depending on the value of the first select field, we will show the other two form elements - one select field (the options depends on the value of the first ...
2 votes
2 answers
3k views

NotFoundHttpException after changing webiste hosting, sub-domain

After changing webiste hosting (Drupal 8) I got this very un-intuitive error message: The website encountered an unexpected error. Please try again later. Symfony\Component\HttpKernel\Exception\...
14 votes
10 answers
18k views

How do I fix a "Mismatched entity and/or field definitions" error on my configuration?

I'm getting the following error on my Drupal 8 configuration page. Entity/field definitions Mismatched entity and/or field definitions The following changes were detected in the entity type and field ...
0 votes
2 answers
2k views

Setup custom required field validation for a field in custom form

How can I setup custom required field validation message for a text field in my custom form. I tried below code. But it is not working. It always showing 'Please fill out this field'. $form['...
1 vote
0 answers
995 views

Field Entity Autocomplete filter the published nodes [closed]

I have a custom form with the following autocomplete entity element. $form['my_element'] = array( '#type' => 'entity_autocomplete', '#placeholder'=>'Search', '#target_type' => 'node', ...
1 vote
1 answer
1k views

error SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

I'm currently migrating my website to D8 and I'm having some issues updating my NEW nodes to match with my live D7 site. I get a few of these for each content type. I think it's from creating "...
1 vote
1 answer
468 views

Prepend drag icon to each form element

I am building a configuration form with a few sortable elements. I know, you can build a table using builtin Drupal draggable functionality (drupal_attach_tabledrag), but it's a bit too complicated ...
1 vote
1 answer
679 views

Integrating external web application

I have an existing web application written in Flask. I want to create a Drupal site that integrates this existing web application, so that the existing webapp will just be a back end, and the Drupal ...
1 vote
1 answer
1k views

Creating multiple destinations from one source

I'm writing a Drupal 8 migration from a non-Drupal site where I need to migrate news articles that have inline images in them, sometimes more than 10. I've figured I'll do this in two steps: A ...
1 vote
1 answer
1k views

Convert Field Collections into Paragraphs during Migration

I have a content type that uses Field Collections in Drupal 7. I am migrating to Drupal 8. Is there a way to convert the Field Collection Entity into Paragraph during migration?
0 votes
1 answer
796 views

How to filter Search API index view by taxonomy parent

I am using the default database server that comes with search api. I have the Hierarchy Index ticked and I also have the taxonomy field that I want selected. Could someone give me instructions on how ...
0 votes
1 answer
221 views

Table view: "Hide Empty Column" checkbox doesn't seem to work

I've created a view, formatted as a table. I'm trying to hide empty columns – so, in the table settings, I've checked the "Hide Empty Column" checkbox for most of the table columns. However, this ...
0 votes
1 answer
472 views

Search not finding search term from page title

Using the default database search index in drupal 8, when I search for a term from the a page title, sometimes it shows the result and sometimes it shows nothing, even though i enter the exact page ...
2 votes
3 answers
1k views

How to get query result in devel?

In Admin we have http://domain.com/devel/php I added query $result = db_query("SELECT name FROM `users_field_data`"); print ($result); It's not showing result. How to show that?
1 vote
2 answers
702 views

Where in the MySQL database schema is the URL alias for a group relation?

I am building a report outside of Drupal that pulls data from a Drupal 8 database. The report shows titles of different nodes and I want to link those titles to the web page for that content. This ...
1 vote
2 answers
1k views

How does one add a Total(s) row to Views results?

After doing some research, it seems like the best way to get a Total(s) row added to a Views table is via the Views Aggregator Plus module. (Is there an easier/better way?) As can be seen below, I'm ...
3 votes
1 answer
625 views

How can I trigger a Drupal Core action without writing any PHP code?

On my D8 site I have configured an action of type "Send email" using the Drupal Core "Actions" module (module can be installed under "Administration > Extend"). I want this Drupal Core action to ...
0 votes
1 answer
1k views

Theme video-embed-iframe.html.twig by content type

I am using Drupal 8 and trying to theme video-embed-iframe.html.twig by content type. with the current naming suggestions this is not possible. I am using Media with video embed field containing in ...
1 vote
1 answer
558 views

Create file through services

I've been trying to create and update users and their pictures through REST calls using the services module. So far, I've got creating and updating users to work, but creating files to set their ...
0 votes
1 answer
462 views

Programmatically add a translation with proper content moderation state

I am trying to add a node translation programmatically when a node is created (using hook_ENTITY_TYPE_insert). My code works fine except that the translation doesn't really have a content moderation ...
4 votes
1 answer
964 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 ...

1
2 3 4 5
316