Questions tagged [8]

Version tag to tag issues specifically related to Drupal 8.x. Please note that 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
38 views

How to run an executable from within a Drupal Controller?

I'm working on a controller that when called upon will take a screenshot of the main page of my site. I'm attempting this by calling Chrome in headless mode via the PHP shell_exec() function. $...
5
votes
3answers
99 views

How to tell if a field has renderable content before printing HTML around it?

I have a half dozen reference fields on a content type that sits at the bottom of a page under a heading of "Related" and some markup structure. I was checking if node.field_name is not empty, ... in ...
0
votes
0answers
22 views

How to use submenu as filter View?

I'm new in Drupal 8, and I want to use submenu as a filter in my page. Example: ParentChild child0 .child1 .child2 When I open the Parent Child page I want that ...
2
votes
1answer
28 views

How to get the media that owns a file?

I have a file and I know there is a media that references it. How can I get this media? In the opposite direction, knowing the media id, I can get the file: $media = Media::load($mid); $fid = $media-...
0
votes
1answer
37 views

Modules folder empty after git clone (submodules ?)

How do you pull/download submodules ? Some of my folder in /contrib/modules are empty after I did a clone of my site. Looking on the Gitlab website, the modules folder got a different icon with a ...
3
votes
1answer
43 views

How can I programmatically distinguish if a block is enabled or disabled from block layout?

I have 2 custom blocks. I have added both this in regions of block layout. But when i disabled the block from layout. I must identify it from code or api that the particular block is disabled. How to ...
0
votes
0answers
33 views

Manually sort Commerce 2 products within the taxonomy term (category)

I have a view to display my products (categorized by taxonomy term) in the frontend. I have another view admin/commerce/products to add new products in the backend. How do I implement and configure ...
0
votes
1answer
59 views

Increasing PHP upload file size in “.htaccess” and “php.ini” not having any effect [closed]

I have tried increasing the limits in php.ini and also in .htaccess as following. php_value upload_max_filesize 30M php_value post_max_size 30M However, "http://drupal-8.dd:8083/admin/reports/status/...
1
vote
1answer
33 views

Error when applying patch

I seem to getting an error when trying to apply a patch and I'm a bit stumped on where I am going wrong if anyone knows that would be fantastic - I need to apply this patch: https://www.drupal.org/...
2
votes
1answer
31 views

How to affect kernel request hostname when bootstrapping from custom PHP script

I'm bootstraping from a custom PHP script using: $autoloader = require_once 'web/autoload.php'; $request = Request::create('/'); // $_SERVER['SERVER_NAME'] = 'whatever'; // $request->server->...
1
vote
1answer
47 views

Create a custom blocks visibility tab (show on certain domain only)

I want to show a block only on a certain domain. I know I can use the domain access module for this but this looks like a to heavy module for my use case. How can a create a custom visibility tab for ...
0
votes
1answer
30 views

JOIN subquery as right table in Views

I have a node field named event_date which contains multiple values of dates. The table for the field looks like this: node__field_event_date +----------------+------------+ | entity_id(nid) | ...
-1
votes
1answer
23 views

Where to include common scripts [duplicate]

I am looking at adding a new javascript library to drupal 8. I want the ability to call this library from other modules / libraries. The way WordPress does this is by the use of wp_enqueue_scripts. ...
0
votes
1answer
35 views

Add inline styles/JS from fields to <head>

My site contains nodes which require different styles (and the occasional inline JS script) and the ability to adjust these styles through the interface rather than via code. These styles are ...
0
votes
0answers
31 views

Trying to make mass webforms more efficient

I have an application that we're migrating in to Drupal 8. Its a system that allows the creation of forms for our clients and then allows the submissions by their clients. We create base forms with ...
0
votes
1answer
41 views

Disable cache a custom block for anonymous user

I have a custom block, it displays in every pages with dynamic data calculates in every refresh, How can I disable cache for this block for anonymous users? I try with: public function build() { ...
0
votes
1answer
51 views

How to use service container correcly?

I want to use service container inside my class so I have this this: class SomeController extends ControllerBase { protected $entityTypeManager; protected $requestStack; public function ...
0
votes
1answer
30 views

DDEV php/twig error “Unknown ”link_attributes“ filter.”

So I'm trying to setup a local environment with ddev for the first time. I got it running, cloned my live files with git and imported my DB. Site ain't working and got this in the log : "PHP message: ...
2
votes
0answers
56 views

Dealing with installed modules/extensions in composer packages removed from composer.json [duplicate]

I had brought up a similar question on StackOverflow, but it hasn't gotten much traction because of a lack of understanding of Drupal, I think. The issue we are experiencing happens when a developer ...
1
vote
1answer
23 views

Job queue – dealing with stuck records

I have a cron job that gets stuck because I have a loop claiming items from the queue that ends on numberOfItems() == 0, which never happens because one of the queue items is stuck and cannot be ...
0
votes
1answer
26 views

How to add HTML5 attribute “autocomplete” to form fields?

According to an accessibility test, I have to add the HTML5 attribute "autocomplete" an the proper tags to all form fields on my website where the user fills in his/ her personal data. E.g. "Your E-...
1
vote
1answer
26 views

Change views exposed filter value only on page reload [duplicate]

Is there a clean way to alter a View exposed filter field, but only on page reload and not each time you submit the exposed filters form ? Example I have a View with exposed filters. When a user is ...
0
votes
1answer
31 views

Alter block form

I'm using the contrib module contact block and I would like to edit the block form settings. By default, there is a textfield (title) and the "Display title" checkbox, I need to hide those fields by ...
1
vote
0answers
49 views

How to customize the front page for each user of specific role?

For my Drupal 8 website I would like to display for the user after login some page /related-content/% where % is a contextual filter and needs to be replaced by the current user id. I have downloaded ...
1
vote
1answer
25 views

Bootstrap simple carousel: how to display it on front-end?

I've installed Bootstrap simple carousel module and I know how to add/edit slides. But I didn't find anywhere instructions on how to display them on the front-end. Module didn't create any new block, ...
0
votes
1answer
17 views

How to normalize / resolve membership ID to all account UID per group_content

I'm trying to add the owner's membership to every GroupContent. By default ownership is only identified by the Account ID. It seems a Normalizer and/or custom resolver is necessary. Beyond my ...
0
votes
1answer
25 views

How do I add more pages to views pagination on mobile?

I'm using Open Social and I want to add more pages to the paginationon mobile phones. One of my views has 11 pages of users and on mobile the pagination is as the following example (<< = ...
0
votes
0answers
46 views

how to convert a timestamp into a date format in a custom module [duplicate]

I created a custom module and printed this outcome in .csv. Name,Event,Email,Timestamp Ea Iustum Jus,Fifa,example@asdf.wer,1573924224 How do I convert the timestamp in a date format? I tried with $...
0
votes
0answers
41 views

How do I pull a value from a Paragraph field and put it in a template? [duplicate]

I would like to pull a value from a field I have in Paragraphs. I have a content type called "Landing Pages" (landing_pages) I have a paragraph type called "Landing Page" (landing_page) The field ...
-1
votes
3answers
50 views

How do I programmatically create a webform from a newly created node?

This is the code I am using. function walk_handler_entity_presave(EntityInterface $entity) { if (method_exists($entity, 'getType') && $entity->getType() === 'walk') { $elements = []; ...
0
votes
0answers
20 views

Migrate one to many relationship

My D8 site has two entities: resource author The resource entity has a field_authors entity reference field with unlimited cardinality. My source data is coming from 3 tables resource author ...
1
vote
1answer
113 views

How to enable click-sorting for views table display based on Search API index?

I'm trying to create a view with table display based on Search API (database search) index, with column-sorting (column set as Sortable in the display settings). However, this option isn't available ...
0
votes
2answers
70 views

Create new node and assign it to user after they have been registered

I have one user role on d8 and have few additional fields on user account so when people are registering they can leave additional data. What I would like to achieve is that when user registers - new ...
1
vote
2answers
84 views

What is the correct way to use a Symfony bundle?

I want to use https://github.com/KnpLabs/KnpSnappyBundle in a Drupal 8 project. How do I correctly use it?
0
votes
0answers
29 views

Displaying translated nodes in views [duplicate]

I am facing a challenge in displaying views for translated contents. Consider a general scenario: Multilingual site with English(site default), German languages. A content type Article has 100 ...
0
votes
0answers
18 views

How to get a second private files directory?

is it possible to create a second private files directory in addition to the existing private files directory? For a better file structure diversity I would like to set a different second location. ...
0
votes
0answers
32 views

Cannot update modules, get a 403 error [closed]

An AJAX HTTP error occurred. HTTP Result Code: 403 Debugging information follows. Path: /core/authorize.php/core/authorize.php?batch=1&id=31&op=do_nojs&op=do StatusText: Forbidden ...
2
votes
1answer
42 views

How do I Install an earlier version of Drupal 8 with composer because install fails on server with PHP 5.6?

My server is using PHP version 5, therefore, I need to install Drupal 8 version 8.6.18. But when I try, composer create-project drupal-composer/drupal-project:8.x-dev my_site_name_dir --no-interaction ...
0
votes
0answers
32 views

webform ajax callback response not updating text, is something missing?

The code below works inside hook_form_alter. The description and price update from database as desired when in form_alter. I moved the code to the callback and now it wont return/update the values. ...
2
votes
1answer
21 views

drush migrate-upgrade “[debug] key_value table not found. Database may be empty.”

I am trying to migrate a D7 site to D8 following the steps found here . Once I can manage it and make sure I have all the PHP components, Drupal modules and etc. I have 4 sites to update, and one ...
0
votes
1answer
11 views

Fill the “Unpublish on” date field of the Scheduler module depending on list field

I have a content type, where I want to give the user only three possibilities to unpublish content: in 1, 3 or 6 months. For the selection of the three options I use a list field. How can I transfer ...
5
votes
1answer
58 views

Is there a way to partially rebuild the router or invalidate a route cache?

I'm using the Groups module (http://dgo.to/group) to set up groups on a SaaS project I'm working on. I've set up a domain field on the groups, allowing groups to have vanity domain. As such, groups ...
1
vote
1answer
28 views

How do I include a twig file in a custom block type module?

I've created a custom module that creates a jumbotron custom block type. The module has an empty .module file and a dir config/install with many .yml files. This works great when I install and create ...
0
votes
0answers
39 views

Get the url of aggregated CSS and JS

I am looking to programmatically get the aggregated url that I can use to pre-load on a different page. Is there a method I can use in Drupal 8 to do this? this url usually looks like: /sites/...
1
vote
0answers
39 views

Entity browser or Media Library for PDF uploads?

Client has a custom Content Type for for downloadable PDF document detail pages, which contains an entity reference to the File media type. They want Full and Teaser view modes to display a thumbnail ...
1
vote
0answers
68 views

Invalidate cache of views block for anonymous users

I have a view display block that needs to be updated every 8 hours. I tried Views Custom Cache Tag module https://www.drupal.org/project/views_custom_cache_tag but I could not make it work. I set my ...
2
votes
2answers
212 views

Where is the node created timestamp stored in the database?

I need to create an SQL query that finds all nodes of a certain type created X days ago, so I can get their IDs. Due to the massive number of nodes in the database, I would prefer to use a direct SQL ...
1
vote
1answer
46 views

How to get the alt tag from an image field in twig?

I have a page of field images which are coming out quite weirdly when I kint their values. I can't seem to get the image url and the alt tag. The code in the twig file looks like this: field--field-...
0
votes
1answer
35 views

How to create paragraph of particular type using JSONAPI?

I am able to GET the data using endpoint "site_url/jsonapi/paragraph/text". But I am not able to create a new paragraph of type text. Its always giving me error "403 forbidden". I have tried all ...
3
votes
1answer
61 views

Saving a webform programmatically in a custom webform handler throws “Entity validation was skipped.”

I am trying to save a webform submission inside the postSave in a CustomWebformHandler class. class CustomWebformHandler extends WebformHandlerBase { [..] public function postSave(...