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
1
vote
0answers
21 views

Views sort handler on dynamic field

Background I've built a custom entity using the drupal console, which was kind enough to implement an instance of EntityViewsData for my entity, called MyEntityViewsData. In the call to ...
-1
votes
1answer
30 views

Multiple or Single Git Repository

Though this isn't about a Drupal issue specifically, it is specific to Drupal. I'm looking for community opinion on best practices for storing multiple versions of Drupal. In my case, I've got a ...
0
votes
1answer
36 views

How can I load webform content inside a custom webform composite element?

I am using Drupal 8.7.3 and Webform 8.x-5.2. I created a custom composite field in a multistep webform by extending WebformCompositeBase. My users select a subject in an earlier step. In this step I ...
0
votes
1answer
39 views

How to Make Managed File Field Available to Twig Template?

I am wanting to make it so that users can upload images to a block configuration form for a pre-existing (views-generated) block (views_exposed_form) and have the images available in the block's ...
1
vote
1answer
30 views

where to put addCommand when implement ajax callback commands

i' m trying to load a dynamic value on every node of my site and i want to achieve this via ajax callback commands and writing custom module so i have a class in src/ajax folder of module like: ...
0
votes
0answers
31 views

How do I migrate content to a field added with UI to an existing custom content entity?

In a custom module (assoc), I have a custom Content Entity (Person) with these fields: $fields['lastname'] = BaseFieldDefinition::create('string') $fields['firstname'] = BaseFieldDefinition::create('...
0
votes
0answers
18 views

Reload only view content on changing exposed filters [on hold]

I am using Better Exposed Filter Module to get filtered rows of view, on every change on filters form (select with cities). Unfortunetly, the response is the whole .js-view-dom-id-xxx, so all my ...
0
votes
1answer
29 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
1answer
33 views

Duplicating content blocks

Is there a way to clone or make copies of blocks? For example, we have some blocks that are quite bespoke. We need to make multiple copies of them so we can display certain content within them on ...
0
votes
1answer
59 views

Before login hook

Is there a Drupal 8 hook for pre-login? I would like to redirect the login information of a user on a web server by URL. I know there is hook_user_login(), but this one only looks called once the ...
2
votes
1answer
36 views

How to get translated field_storage_config

I need to programmatically set the translated values for several fields on a node. For that I would like to set their values in the fields field_storage_config. Adapted from another question's answer (...
-2
votes
1answer
33 views

how to rearrange a contents type in view?

I have created a view using 8 content type ,then i choose page display setting Display format :Grid full post Settings :number of columns 2 Alignment : vertical Then view like Content A ...
0
votes
1answer
31 views

Get field machine name inside HOOK_preprocess_file_link()?

I am hoping to get the field name inside the HOOK_preprocess_file_link. Only wanting to alter the link of the file for certain field names. Hook_preprocess_field() would probably work, but would ...
0
votes
0answers
30 views

Save value in form with multiple instances in same page

This is my buildForm function: class NewsletterForm extends FormBase { // ... public function buildForm(array $form, FormStateInterface $form_state, $newsletter_list = NULL) { $form_state->...
0
votes
0answers
29 views

Setting a field value in a hook_preprocess, then the field has its original value in twig?

Inside of a hook_preprocess_hook, I'm setting the value of a field as follows: $mainTab->get('field_url_alias')->setValue($url) I've verified that this value is actually being set correctly. ...
0
votes
0answers
22 views

Is there a dd() like variable printer that can be used inside a preprocess?

Many times when I start a hook_preprocess_hook, I start by printing the $vars object. I can do this by dpm()'ing, dsm()'ing, kint()'ing etc. The problem is that all of these functions print $vars in ...
1
vote
1answer
33 views

How to post a node tags using REST API?

There is no problem with a node creation with filled in title/body/custom text field fields using REST API. We just need to send a post request with the following body: { "_links": { "type": { ...
0
votes
0answers
24 views

Nginx virtual host configuration for multisite with sub-directory

We've Drupal multi-site (with different domain per site) running with single Drupal 8 code base and nginx. Now we wanted to setup Drupal Milti-site with sub-directory for few websites in following ...
0
votes
0answers
11 views

Get replaced element value in ajax

On ajax callback I have replaced value on with replaceCommand> Value was displaying on browser but , while i have clicked on radios again and ajax callback again It will fetch the same old 1000 value ...
0
votes
0answers
28 views

What should I use instead of ajax_render()?

I want to create AJAX pagination on Drupal 8. With Drupal 7, I used the following code. $result = theme('load_more_friend_suggestions', array('friends' => $friends_list, 'info' => array('...
0
votes
0answers
35 views

Batch API is repeatedly running on the same chunk of data

I keep seeing two different styles of preparing batch jobs. The first example will create a multi-dimensional array of multiple operations, each containing a chunk of the overall data, as such: ...
-1
votes
1answer
39 views

Automatically export submissions as PDF to a directory on the server, or external location

Background Drupal 8 have a great new feature: Ability to use entity_print to export submissions as pdf, and even to attach the pdf to email and send. Request Because of the sensitivity of some ...
-2
votes
0answers
28 views

How to visit page as authenticated user programmatically

How can I programmatically visit a page as an authenticated user in Drupal 8? $response = \Drupal::httpClient()->get($uri, array('headers' => array('Accept' => 'text/plain'))); $data = (...
0
votes
1answer
36 views

Add a conditional CSS class to the label of the view exposed form

I try to add a CSS class sr-only to the label of my Views exposed form. In form-element-label.html.twig I added: {% if title is not empty or required -%} <label{{ attributes.addClass(classes) }}...
0
votes
1answer
59 views

Print custom product variation field in order email confirmation

Added custom field ('field_secretkey') under Commerce - Product variation (admin/commerce/config/product-variation-types). I am able to get this value in Orders view by adding the "Product variation"...
0
votes
2answers
45 views

Running a queue worker without using cron tasks

I implemented hook_queue_info() with the following code. function ecc_general_queue_info() { $queues = array(); $queues['adding_checklist'] = array( 'worker callback' => '...
0
votes
0answers
21 views

Ajax based form doesn't work on new from element [duplicate]

I am creating some dynamic form element based on the dropdown selection. There are max 3 dropdowns and I want to run ajax on each dropdown on change event. When I clicked on the first dropdown(Level ...
0
votes
1answer
26 views

How can I programmatically create an entity with an entity reference field?

I want to create an ECK programmatically, I can create it but the issue is with the entity reference fields that being empty The interesting issue is that when I try to edit the created entity, just ...
0
votes
1answer
36 views

Custom module files written in Windows aren't being recognized when migrated to Linux

I've developed several custom modules in my development environment. My current development environment is Drupal 8 in XAMPP running under Windows and I write the code in Netbeans. I'm getting close ...
0
votes
1answer
24 views

Is it possible to generate an URL object from a path?

Can I generate a https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Url.php/class/Url/8.2.x from a simple path, e.g. "/products/widget" ? (assume /products/widget exists in the system ...
0
votes
0answers
11 views

Ajax loader when facet is selected

When we add a facet block to the page, a filter is selected and the page starts to load the results. However there is no loading icon or indicator the change is being applied. When we check the page,...
-2
votes
0answers
25 views

How can I avoid recreating a node?

Let's say I want to save a node programmatically and the following function will be called inside a foreach loop for each event object. Therefore, a event object will be saved as a drupal node with ...
1
vote
1answer
32 views

Focus problem when Ajax call for multiple fields calling the same callback function

I have implemented a custom form. I put same Ajax callback function for multiple field. When one Ajax call completes, I click on other field. But I can't unfocused previous field. Sometimes the Ajax ...
-1
votes
1answer
38 views

I removed the module from my site and now I'm getting an entity type error

I have an issue where I removed the paragraphs and bootstrap_paragraphs modules from my site and now I am unable to access the admin or the site. It is saying that the paragraphs entity type doesn't ...
1
vote
2answers
74 views

Wrap a link around a block in Twig

I have a block and I’m trying to wrap a link around it: {% block paragraph %} <div{{ attributes.addClass(classes) }}> {% block content %} <a href="{{ content.field_link.0['#url'...
0
votes
1answer
29 views

Delete a field from the database manually

I installed a module that left a ghost field that isn't tied to any entity bundle :( How would I go about safely and thoroughly deleting this field from the database? I have to delete this field to ...
0
votes
1answer
15 views

Changing a menu link used in the sitemap module but not in main nav

We are using the Sitemap module for creating a sitemap generated from three menus (Footer, Main nav and a 3rd arbitrary one). In the main nav we have a placeholder LI element which we use to insert a ...
-3
votes
0answers
20 views

Has anyone any suggestions about making regions and their content exported In order to use them for a headless site?

Has anyone any suggestions about making regions and their content exported In order to use them for headless drupal? Or the only suggestion is progressively decoupled drupal?
0
votes
0answers
21 views

Get price value in Webform submission

I'm trying to create a webform that has an entity selection element linked to an entity reference view that has a selection of products from the commerce module listed. So far this has all been ...
-1
votes
1answer
53 views

Which hook can I use to retrieve form values after submitting a webform? [duplicate]

As the title suggests, I would like to know what is the correct hook for retrieving datas after a submission. The goal is to do a task based on the value of a data. Any help would be appreciated.
2
votes
1answer
46 views

How to override ViewsExposedFilterBlock with my own class?

I want to add an additional form element in the configuration form for core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php by adding public function buildConfigurationForm(array $form, ...
1
vote
1answer
21 views

Change order of breadcrumbs elements in hook hook_system_breadcrumb_alter

I want to add another element to breadcrumb. I have: Home > Node Title I want to add another link between the two elements like: Home > Link to view > Node Title I have tried with ...
0
votes
1answer
22 views

Render image field with custom image style in custom block template

This is basically the same question as this, but I can't get the technique to work in a custom block type template: https://drupal.stackexchange.com/a/219052/71100 I have a custom block type called ...
1
vote
2answers
25 views

Entity access controler not called from custom route

I define a custom entity named "Politician", where I set the class PoliticianAccessControl as an access handler. This is working fine for the canonical url of the entity set in the following way: ...
1
vote
1answer
25 views

How to delete paragraph when uninstalling the module?

I have been creating the custom module which have the paragraph configuration, when installing the custom module, the paragraph config will be stored in the database and then It will be available in ...
0
votes
0answers
21 views

Unit testing a block's build() method

I don't have too much experience in writing tests (especially for Drupal), so I was wondering if this is a good approach to test the build() method of a block? Assuming this is my block provider code:...
0
votes
0answers
27 views

How to theme field collection form in Drupal 8?

I want to theme the field collection add and edit form. I have a field collection name "field_experience" and want to theme the form of that field collection I tried field--field-experience.html.twig, ...
-1
votes
0answers
31 views

How to print the file name in Twig [duplicate]

I have title and filename in {{item.content}} then i tried to iterate title like {{ item.content['#title'] }} Which is working well.similarly i tried to iterate filename like {{ item.content['...
0
votes
0answers
25 views

Fatal error: Class 'Archive_Tar' not found in ArchiveTar.php on line 8

Rather than re-explaining the whole process that got me here, I'm hoping I can just reference this question: Can't access specific admin pages In that question, I was hitting errors while trying ...
0
votes
1answer
53 views

Drupal 8 migrating json data with no array label

I'm learning how to create migrations in D8. However, I have this annoying issue where my migration is listed when I execute drush migrate-status but the total and unprocessed values are shown as N/A, ...