Questions tagged [8]

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

Filter by
Sorted by
Tagged with
2
votes
4answers
9k views

How do I fix this Configuration Directory sync error?

I can't get past this error while installing drupal on my localhost. I've chmod'ed permissions on my core /default directory. I've: /default on 755 /default/files including all subfolders and files ...
0
votes
2answers
2k views

How to load customer profile from address module (commerce)

I'm using Drupal 8 with the module Commerce and I have an issue with the customer address. I'm developing an export custom module in D8, and I'm stuck trying to load the profile (to access billing ...
1
vote
1answer
734 views

Create custom endpoints by extending the Resource Base class

I created a custom endpoints by extending the core of Drupal. but I can not retrieve JSON data. I do not know what value to put in 'note: serialization_class /** * Provides a resource to get bundles ...
0
votes
1answer
21 views

How to pass variables to template to use it in email?

I've written a "hook_mail()" to send html emails. I have everything but I would like to use a custom template. I use a "hook_theme" as well, but my question is how can I pass variables to use it in my ...
1
vote
2answers
2k views

How do I create a conditional form field?

I have this dropdown menu of options in the user registration page of my site (image shown below), and i want when the user selects the employer, some text fields appear, like name of company, and ...
0
votes
2answers
40 views

Duplicate content between multi-sites

I'm working on a feature of a Drupal 8 multisite with separated databases for each site trying to implement the following requisite. When posting news to the main site (all the other sites are ...
0
votes
0answers
47 views

Page title not being rendered after page refresh (possible cache issue)

This is the problem at hand: the first time I access a page after a cache rebuild, the title of said page is displayed correctly. But when I refresh (or access it later after navigating other pages) ...
1
vote
1answer
458 views

Override breadcrumbs is not present?

In Drupal 7, in the views with an argument, is easy to override both title and breadcrumbs. Now in Drupal 8 I can't find the option. Did I miss something? or isn't possible? In this case what is ...
2
votes
2answers
1k views

How to add UniqueField constraint on integer field?

The title basically says it all. I have the following field definition in an Entity class: $fields['code'] = BaseFieldDefinition::create('integer') ->setLabel(t('unique code')) -&...
-1
votes
0answers
16 views

How can I add a sitewide proxy to the HTTP client service?

On a particular environment, all the external requests via Drupal's HTTP client (http_client service) should go through the proxy. However, there is no option to set proxy details on each environment ...
0
votes
0answers
20 views

How to reference webform field option?

So I have webform module installed and I created a webform. Webform has an choice field (drop-down). Let's say you can select one of 3 options: "one", "two", "three". I need a way to add (editable) ...
0
votes
0answers
23 views

How can I override the form-element-label.html.twig template?

In a view, I have checkboxes displayed using the better-exposed filter. Ajax setting is true. Currently, there is no template suggestion for overriding form-element-label.html.twig. Somehow by adding ...
1
vote
2answers
276 views

Modifying page title with THEME_preprocess_page_title

I'm running Drupal 8.2.6, and an Adaptive subtheme and I am trying to modify the page title. I have created the following function in THEME.theme function THEME_preprocess_page_title(&$variables) ...
3
votes
1answer
432 views

Invalid Argument Exception when saving a view using a custom filter handler

I am working on a project which implements a custom views filter; more specifically based on the InOperator class. I have been following the guide below to implement the custom filter: Creating a ...
5
votes
3answers
16k views

How do I retrieve the query parameters from a path?

How do I retrieve the query parameters from a path. Here's my path: /search?keys=hello Here is what I've tried: $test1 = \Drupal::request()->request->get('name'); $test2 = \Drupal::request()...
1
vote
2answers
1k views

How can I log(watchdog)?

In D7 is used to log using Watchdog function. In D8, I see its gone and I should use something called the logging API. What I a trying to do: I have created a menu/route, mysite.com/logmessage When ...
0
votes
0answers
31 views

Import a node with paragraphs [on hold]

I would like to import node with multiple paragraphs, but I can't make the Feeds module work with paragraphs. This is a sample of XML data that needs to be uploaded. <test-feed> <...
0
votes
2answers
461 views

How do I change the field format? [on hold]

I have a view (page display) with few fields. I want to change one field's format to HTML markup. How can I do it programmatically by using hook_views_pre_render() or perhaps any other hook_?
4
votes
5answers
4k views

Programmatically get View Custom Text

I created a view with a "Custom text" field and want to get this field programmatically in Drupal 8. I have: $view = Views::getView('my_view'); $view->execute(); foreach($view->result as $row){...
0
votes
0answers
23 views

How to get the values of web form remote post handler?

i have created a web form handler ie. Remote post Handler. and i have gave one URL for posting the submitted data. How to access those submitted values in that particular page. How to GET ...
0
votes
1answer
1k views

How to make a regular expression case insensitive?

I am working on a Drupal Commerce shipping rule and it needs a regular expression to compare postcodes with the buyers address as below; /^AB37|^AB38|^AB41/ I am finding this code to be case ...
6
votes
2answers
15k views

Rendering an image field in page.html.twig with a custom image style

I'm trying to set up a slideshow that's unique to each page. The code for this needs to be in page.html.twig. I've got the slideshow mostly working, but I can only call the full image URL, not a ...
1
vote
1answer
476 views

How to set a value programatically only when a content type is saved for the first time?

I'm trying to record the user agent string into a text field (field_useragent) the first time a content type is saved. This is what I tried: /* * Implements hook_ENTITY_TYPE_insert() */ function ...
1
vote
2answers
516 views

How to add a taxonomy term value as a class?

I am trying to target a specific div with CSS. But for that, I need a unique class in order to target a specific taxonomy term. I look at this question, but that doesn't work as it will target all ...
1
vote
2answers
3k views

“Uncaught TypeError: Cannot read property 'getAttribute' of undefined”

There are some posts about this error for Drupal 7, but I'm using Drupal 8.1 and those solutions don't work for D8. I tried this patch (coded for D7) and doesn't work. The effect of the error is ...
2
votes
1answer
24 views

Migrating csv data as array into multi-field

How do I migrate a sequence of data into a multi-value field? I am learning D8 migration and working on a large CSV of historic census data from around the world. Example below: id,Country Name,...
2
votes
3answers
461 views

Syncing content between stage and prod [closed]

Drupal 8, two versions of a site - dev and production. How to move changes, especially changes in content from dev to production without destroying DB on production? I know we have Features for ...
1
vote
2answers
1k views

Add property to existing field type

I have troubles adding a simple additional properties (like alt or title) to the image field type. In the .module file I defined an alternative class for the image field. function ...
0
votes
0answers
35 views

Caching user profile image? [duplicate]

If I log in as User 1, i see user 1's profile picture. If I log in as User 2, I see user 2's profile picture. As expected. But after browsing a bit, User 2 would suddenly see User 1's profile picture. ...
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 ...
1
vote
2answers
2k views

Entity form with pre-populated entity reference from URL

I have two entities which are in a parent/child relationship. Now I want to add a operations link in the parent's list view so that I can show the child's entity form with the reference to the parent ...
0
votes
1answer
487 views

How can I copy block placements and settings between themes?

How to copy blocks placement and settings between themes? suggests that, in Drupal 7, I could run the following two SQL queries to copy block placements and settings between themes. DELETE FROM block ...
0
votes
1answer
1k views

Skipping form validation with a custom action button

Related to my previous question -- I've got the button added to the form properly (thanks googletorp!), but now I'm having separate validation issues beyond just adding the button. I have added a "...
1
vote
1answer
48 views

How to write test(s) with specific config to test custom access checks?

I have built a custom module that alters some of the User routes (view, edit, delete) to do 3 things: Forbid account editing, except a user who has 'administer users' permission Forbid account ...
1
vote
1answer
490 views

Custom sort with search api

I have created a ViewsSort plugin that works on a normal view (like taxonomy_term) but not on a view based on Search API : it is not present when I click on "Add sort" in BO. This sort is used to ...
8
votes
3answers
4k views

How to solve the “The following module is missing from the file system” error?

I am getting the following error in a Drupal 8 site. The following module is missing from the file system It looks as if a custom module was installed and deleted without uninstalling it. How ...
0
votes
0answers
20 views

Follow symlinks inside of default/files

I am running Drupal 8.7.6. The default/files directory is a symlinked to a read only mount (/mnt/files_ro). Drupal needs to write inside a few folders as it aggregates and caches assets, so I created ...
-3
votes
1answer
30 views

Required fields [closed]

I'm doing a migration from csv to Drupal 8 and I'm not sure how to handle the required fields. My content type "Department" has 8 required fields, should I use the plugin "skip_on_empty" in every ...
0
votes
0answers
38 views

How can I replace static file and media links in content with their equivalent entity references?

I imported content from another system. So, for example, the body has typical html, like this: <img src="/images/image.jpg /> All of the media assets that are referenced as static html, those ...
0
votes
0answers
15 views

Setting default upload paths for media

I really want to have an organised files folder in my d8 project. I have two main media fields: field_banner AND field_image They appear in all my content types. I would like that all the the media ...
0
votes
1answer
797 views

How do I get a URL variable in a template?

I am trying to include a certain .html file if the URL has ?work=1. So far I have this, which I got from Check URL for string in a Twig file. {% if 'work' in url %} {{ include('work/index.html'...
15
votes
5answers
20k views

How to get each field value in views-views-unformatted--view-machine-name.html.twig?

I have an twig file: views-view-unformatted--view-machine-name.html.twig {# /** * @file * Default theme implementation to display a view of unformatted rows. * * Available variables: * - title: ...
0
votes
0answers
18 views

jsDelivr CDN provider does not work using bootstrap for drupal [closed]

So I'm trying to create a drupal theme with bootstrap. However my boostrap does not get loaded due to malfunctions of jsDelivr (I think). PS: Does anyone know some good Drupal guides/books? Because I ...
0
votes
1answer
368 views

Export and Import Taxonomies and Extra Fields

I created extra field in Login Form, I Installed even Extra Module (address) and create Taxonomies Now I want to Export these configurations to another Drupal. This Drupal is the Clone of the main ...
0
votes
2answers
360 views

How to handle multiple URLs in Drupal migrations

I have a drupal migration that also uses migrate plus from a feed URL that can be queried. For example the migration can work for a single response from the feed at source: plugin: url ...
2
votes
1answer
3k views

How do I remove the title field from a node's custom view mode

In my Drupal 8 website I created a custom view mode through the UI. I use it to output nodes using a view. In the view result I do not want the titles of the nodes to appear. The UI (content type > ...
0
votes
1answer
23 views

How to remove tags from display in form?

I have this form tempate <div class="a"> {{ form.card.a }} </div> <div class="a"> {{ form.card.b }} </div> and I want to to frame it with tag like this. <a href="...
0
votes
1answer
593 views

How to identify item_selector for Migrate API JSON imports

Trying to import articles from an external JSON feed of "members" with a structure like this: { "status":"OK", "results":[ { "num_results": 10, "offset": 0, "...
1
vote
0answers
32 views

Change field type for custom entity (from integer to decimal) with existing data

Yes I have seen previous answers about that, but I'm looking for an new answer : That does not use SQL request That does not use deprecated function like db_change_field() maybe that uses the new ...
-2
votes
0answers
29 views

How do I create a menu item from view results [closed]

My organization has several Departments. Some of these Departments have websites. Some do not. I have a Department Content Type. These Departments have an optional website field. I have a view that ...