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
-2
votes
0answers
39 views

How can I trigger a file upload?

I have a file field on a page. On that page, I have images using image tags. When I click on the image, I want to upload it to that file field. Just like we select an image from our computer and it is ...
0
votes
1answer
17 views

Trigger Crop API programatically after node is created

Hi I am using Image Widget Crop so that users can crop images according to predefined image styles. All would have worked fine without any issues had I been using Drupal in the conventional '...
0
votes
1answer
42 views

How do I prevent node enumeration?

I am currently developing a Drupal 8 site that will consist of one only central content type with a minimal menu structure. The user is supposed to navigate the site only by using a search/filter form ...
0
votes
1answer
31 views

How to create Media video youtube entity programmatically? [closed]

I have file with multiple Youtube URLs such as: https://www.youtube.com/watch?v=asddasOds32 https://www.youtube.com/watch?v=kjh234hknnn https://www.youtube.com/watch?v=iZ53yuirewn ... I need to fill ...
0
votes
0answers
86 views

Dynamic block cache doesn't render

I have a menu that renders different items based on the entity association of the node being rendered. I've been trying many difference combinations of cache configurations for my custom block: ...
2
votes
2answers
34 views

What is the replacement for menu_link_load()?

Drupal 7 has menu_link_load() to load a single menu item. What is the Drupal 8 equivalent?
-1
votes
0answers
20 views

Upgrading from 8.8.5 to 8.9.5: Getting 'Requirement Problem' error

I am trying to upgrade from d8.8.5 to d8.9.5 and I'm getting a requirements problem immediately after running update.php See screenshots It seems there's some table missing from database schema ...
-2
votes
1answer
52 views

How to automatically flag entities once (without PHP error)?

I created a custom module to automatically flag new entities and update entities. It works :-) Here is the problem : If I update a neud it is flagged. Perfect that's what I want to do, but if I update ...
0
votes
1answer
48 views

Custom block build function to display wysiwyg body text

I am learning to build custom blocks through a module. I am trying to get the build() function to work. I have the code and it works. However, if I edit the configuration of the block as a user it ...
0
votes
0answers
19 views

How do I generate a search snippet similar to core search for a custom search API page?

I installed solr and search_api and search_api_pages. It's all working as expected but, for now, my new search page need a lot of configuration to display correctly. Unlike drupal core search, which ...
0
votes
1answer
24 views

Form API placeholder attribute rendered as “- Select -”

In a custom Drupal 8 module, I have a couple of Form API fields of '#type' => 'select': <? $form['form-right']['field_role'] = [ '#type' => 'select', '#title' => $this->...
-1
votes
0answers
25 views

Is it possible to select items in page and order by drag and drop them in another page in a multi pages form?

As in https://www.drupal.org/project/webform/issues/3037186 i'm asking the same request here as suggested in the issue On Drupal8 and Webform, is there a way to have something like that : user ...
1
vote
1answer
26 views

Exclude nodes referenced from another content type's node

I have two content type: Content type A Content type B In content type B I have one reference field which referencing Content type A. Now I want to build a list of Content type A, which is not ...
-2
votes
1answer
39 views

Custom block theme not appearing in QuickTabs content

I'm attempting to create a dashboard page that contains 4 tabs that are each a block that will contain a content based on the current user. I went ahead and created the 4 blocks (bl1, bl2, bl3, and ...
1
vote
1answer
26 views

Content moderation - workflows / weird behavior

I have set a content moderation workflows for my content type : Draft and Published states. Pretty basic, i create a content in Draft which is not published, i can change the moderation_state to ...
-1
votes
1answer
75 views

How do I flag new user accounts or updated accounts?

I created a custom module to automatically flag new user accounts and updated accounts. When I create a new user or update an existing account, it is not automatically flagged and there is no error ...
0
votes
0answers
26 views

Execute command line script in module file

I am using Drupal 8.9.5 and I need to compile a SCSS file using Gulp command in our module file. If I execute the command from the command prompt, it works without any issues, but when I tried from ...
0
votes
0answers
25 views

I want to reset a managed_file field after AJAX form submission

I implemented a form with managed_file field. $form['field_name'] = array( '#type' => 'managed_file', '#upload_location' => 'public://node_file/', '#upload_validators' => array( '...
0
votes
0answers
14 views

Displaying sub content (entity references) of node based only with specific taxonomy

I have been working on a solution that would allow training courses to be created using Drupal 8 as the backbone. I have elected not to use the "Courses" module and am simply using custom ...
0
votes
1answer
54 views

Get a session value in a template file

I am trying to get value set in session in a template file, but I don't get the expected value. I tried two methods, but neither of them works for me. The code in the custom module controller is the ...
0
votes
0answers
25 views

Drush Launcher looking for Drush in public_html when using updb

I have a drupal 8 website up and running on a server. On this server I use the Drush Launcher to work with Drush on my site. For some reason the Drush command drush updb doesn't work I get the ...
0
votes
2answers
55 views

How do you target a specific type of content?

I have the content type (node), article, page, recipe. The code below can be used to flag any type of content. How do you target a specific type of content ? For example I only want to flag the ...
0
votes
0answers
17 views

How do I prevent anonymous users from modifying and deleting their submissions after a webform closes?

I'm using Drupal 8.9.6 and Webform 5.20 Background I have an event that lasts 7 days and I've created a registration webform (using Webform Nodes) for each day. Each webform gives anonymous users the ...
0
votes
1answer
30 views

How do I get the administrator to automatically flag?

I created a module for flagging entities automatically when created or updated. There are some errors in my code because only nodes work. If a user "user1" creates a node, the flag will be ...
2
votes
1answer
29 views

“Order items” view displaying removed items (variations)?

I'm dynamically removing items from cart with this function: static function _remove_product_variation_from_cart($variationId) { $orders = \Drupal::service('commerce_cart.cart_provider')->...
0
votes
1answer
20 views

Setting node ID sequence to a particular higher value for future created records

We have an organic groups based portal in D7 where many blood banks add records. We recently initiated Drupal 8 migration and are close to completion. However, we would want to add selective blood ...
0
votes
1answer
61 views

How do I flag the update store automatically?

I created a flag to flag the stores. I want when a user updates a store, the store is automatically flagged. The code below does not work and there is no error message. I don't want to use the Rules ...
0
votes
1answer
40 views

Count multivalue image field values in views-view-fields.html.twig

Making a presentation template for the gallery. The photo gallery has an image field with multiple values. I need to output the number of gallery photos (in the field_gallery_photo). How do I do this? ...
1
vote
1answer
43 views

How do I track a publicly downloaded file?

I am creating a custom module to track the file download time and user id with a file link or path. I have tried multiple modules but the download the file time tracking option is not available. How I ...
0
votes
1answer
44 views

How to properly program AJAX links?

I have a custom module that uses AJAX. Everything works fine the way it is. I'm just wondering if it's the proper way to do it in Drupal. I'm new to Drupal 8 and 9 programming This is a line from my ...
-1
votes
1answer
56 views

Cannot flag nodes and comments automatically

I created a code to automatically flag nodes and comments. When I put only the code to flag the nodes, it works. But when I add the code to flag the comments it doesn't work anymore. Which code should ...
0
votes
1answer
26 views

Why there is not loadData() method in FileSystem?

To use the private:// scheme of Drupal 8 I had to : Create a folder outside the docroot folder Implement a $settings['file_private_path'] = '../private-files'; to designate this folder Make sure ...
2
votes
2answers
49 views

Non-blocking HTTP request with Guzzle

Is there a Drupal 8 way to do non-blocking HTTP client request using Guzzle? I don't need to wait for the answer of The HTTP post, as that is slowing down the site. I already seen Non-blocking ...
0
votes
0answers
45 views

Set condition using rule module to pass one content type field's value in second content type

I have created two content type Album details and Photos of album. In Photos of album content type i added field (Entity reference type of first content type i.e Album details) and widget as select ...
0
votes
1answer
26 views

Allow authorization via cookies

We are migrating from Drupal 7 to Drupal 8 and are currently at the last hurdle - relying on Drupal's session to authenticate for custom scripts. Previously we used to rely on drupal_bootstrap but now ...
0
votes
0answers
14 views

Jsonapi cross bundles module usage

I'm setting up a Drupal API, using jsonapi. In the frontend application, we would like to get all content, regardless of content type, with one request. I came across this issue that adresses exactly ...
1
vote
1answer
120 views

Allow shipping that is calculated using a base rate plus a rate per item?

I figured this would be built in, but it seems it is not. See here: I have two options: Flat rate: I can make it 9.99 USD, but then if it's 100 items, it's still 9.99 USD. I can make it 1 USD per ...
0
votes
1answer
53 views

How do I translate Field Group labels?

I have two field sets In the admin/config/regional/translate I have translated the "Account settings" label But in the Form display I still have the english label: What can I do to ...
2
votes
2answers
91 views

Custom view sort plugin not working only when used in table sorting

We have a view of committee memberships (= custom entity). The committee memberships hold references to the committee and the politician and have a field "role". In a view we want to output ...
0
votes
0answers
26 views

Migrating multivalue link fields from CSV

I am trying to migrate data from D7 to D8 using Drupal Migrate with source CSV. I am able to import all the data except multivalue link field. With the help of examples from Migrate Plus, I am able to ...
1
vote
1answer
46 views

How to get the parameter value from an ajax call in the page controller?

I have the following js code according to es6. (($, Drupal) => { Drupal.behaviors.mymodule = { attach: () => { document.querySelectorAll("a").forEach(element => { ...
2
votes
2answers
79 views

Can users be forced to insert only plain text by default in CKEditor?

I know there is "Paste Text" button in CKEditor, and I can limit allowed HTML tags. But it's very hard to explain clients to use specific button when they insert text. As result they often ...
0
votes
1answer
24 views

Change data export download link label

I want to change the label shown to export csv file download link that generated with data export of a view. I didn't get any setting to change the label of download link - download full list.
0
votes
2answers
30 views

How do I limit access to a custom field type I have created so that it can only be attached to certain bundles of content?

I have a custom field class. I would like to limit it to specific content types and bundles that I will choose when my custom module is installed and as other content types meet certain criteria. I ...
0
votes
1answer
38 views

How to force a JS library to be loaded via HTTPS?

How can I force a js library to always load only via SSL? Specifically, I want to get Drupal to always load stripe.js with SSL, because stripe.js refuses to load over http (you get a 403 FORBIDDEN ...
1
vote
1answer
61 views

EventSubscriber returning correct content but status code is 404

As the title says, content is being returned correctly but the status code is 404. I have checked the .htaccess file and the Apache config file as well. All seems to be fine. I have the following in ...
1
vote
1answer
34 views

Is it possible to combine two filter criteria exposed filter into one dropdown

Is it possible to combine two filter criteria exposed filter into one dropdown. In drupal 8 I am creating a view to search certain content type. One of the content type has three select list field, I ...
0
votes
1answer
33 views

How can I automatically flag new comments?

I have a Drupal 8 site with Flag and Rules modules. How to flag a new comment ? I want that when a user creates a comment, the comment should be automatically flagged. I created a type of Flag on the ...
0
votes
1answer
22 views

How to round the total price, display without decimal? [closed]

I need to count on decimal places (tax, promotion, fee ...), but the total price must be mathematically rounded without decimals. Example: 2 x product1 CZK 424.00 1 x Product2 CZK 408.00 Subtotal CZK ...
0
votes
1answer
49 views

Save customer information at checkout

My customers are required to provide an address at checkout (Shipping information pane). They can also create an account after checkout is complete (Guest registration after checkout pane). But the ...