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
0
votes
1answer
28 views

Add modifier class to module block on custom content type

I'm trying to alter the display of a social media share block module im using on my site on a custom content type. All throughout the site the share block looks like this, floating on the left side of ...
3
votes
1answer
106 views

How can I let authenticated users rebuild caches?

Is there a way for authenticated users to clear the cache without giving them the administer site permission?
2
votes
1answer
845 views

How do I integrate media (e.g. attaching audio) to nodes?

I installed the Media Entity module for Drupal 8. I thought it would somehow facilitate adding Mp3, etc, as Media does in Drupal 7, where I could specify a media player type for an audio file. (And ...
-2
votes
1answer
49 views

How to call method of controller in .module file with dependency injection

I have class named Book. class Popups { private $entityQuery; private $entityTypeManager; public function __construct(QueryFactory $entityQuery, EntityTypeManagerInterface $entity_type_manager)...
1
vote
1answer
24 views

Translatable image field gets replaced when adding content

I have added an image field with Translatable Content enabled. My content type has enabled translations too. But when I add an image in the translation, the english contents field get replaced with ...
2
votes
1answer
49 views

Is there a way to run hook_form_alter after themes implementation?

I'm using the material_admin theme, which has a hook_form_alter() implementation. I see that my module's hook_form_alter() is executed before the theme hook. Both hooks are editing the same form ...
0
votes
1answer
36 views

Show form errors before opening AJAX modal

I have a form that adds a product to the cart. The form uses AJAX to open a modal when the form is submitted. I want to show form errors (if any) before the modal opens and avoid opening it if there ...
0
votes
1answer
356 views

How to identify a paragraph?

Is there a way to identify a paragraph in Drupal 8. Like is there a function to get the type as paragraph in code level? I need to get it from a form alter function. My requirement is to get all the ...
0
votes
0answers
14 views

Get real (unaliased) url [duplicate]

I need to find out the real (unaliased) url for some pages. I tried \Drupal::request()->getPathInfo() and \Drupal::request()->getRequestUri() but they return the aliased path. Also, i looked at ...
5
votes
2answers
2k views

Is there any way to reuse the same file or image?

Is there any way to reuse the same file or image while uploading I just worry about having multiple/duplicate image files on the server - in time it could get full and slow down the server. I have ...
0
votes
1answer
680 views

Why when I do a configuration export does the config.tar.gz in tmp not get copied to the sync folder?

This happens when I use the UI and drush cex. The config.tar.gz is created in the tmp folder but nothing is created in the sync folder that I created in sites/default. I have searched for similar ...
18
votes
4answers
24k views

Get all nodes of given type

I would like to get all nodes that are of my_custom_type type in Drupal 8. I know I can get all the nodes (of any type) with \Drupal\node\Entity\Node::loadMultiple() and the list of all types by \...
0
votes
1answer
22 views

How do I get the menu block choice “Expand all menu items” to stay checked

I have 2x menu blocks. One in the header and one in the footer. I'd like the header one to stay unexpanded, but expand all the items in the footer. When I check "Expand all menu items" in the footer,...
0
votes
3answers
66 views

call a custom JS function once

I understand once() can be used on a jquery selector method to make sure it is triggered only once. How to do the same with custom functions? My function wakeUpAndRemember is called 5 times which is ...
-2
votes
1answer
23 views

Webform Group Member Composite

I need to create a Webform element that has a list of group members, each with their own checkboxes and text fields ('job description'). I figured out how to display checkable group members through a ...
3
votes
1answer
1k views

How to get all parent nodes from a menu item?

Imagine the following menu structure: Page 1 type: article Page 2 comes from a view Page 3 type: desirable < want this Page 4 type: random Page 5 type: random Page 6 type: article Lets say I'...
17
votes
4answers
13k views

Access user fields?

$account = \Drupal::currentUser() loads the user object into $account, but how do I access custom fields I've created on the user object (via the admin UI)? With dpm($account) I can't see any of my ...
1
vote
1answer
813 views

Custom wrapper field

I have a normal field submit: $form['submit'] = [ '#type' => 'submit', '#value' => 'Submit, ]; But I wish he had a complex wrapper without using #prefix and #suffix. This wrapper also has ...
0
votes
1answer
104 views

Can't render node view mode programmatically

I try to render an HTML data from my node view mode but unfortunately, I have some small progress. I did some searching and modification on the others code Here. I have this now. $nid = 145; $...
-2
votes
2answers
91 views

Search by reference field target ID [closed]

I have a Project content type, which has a reference field to a Contact entity that has a Client bundle. I can get the reference target ID from the node. I want to find the nodes that contain a ...
0
votes
1answer
36 views

Store entity with entity reference field? [closed]

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
61 views

Blocking JS from being executed more than once

JS lines of code are often executed more than once. How can this ( annoying ) behaviour be blocked? (function ($, Drupal) { 'use strict'; Drupal.behaviors.recherche = { attach: function (...
0
votes
3answers
457 views

Allow access to user information without giving access to view user profile page

The main concern is: Nobody (anonymous/authenticated) has the permission to see the profile of any registered user on the site, so I have UNCHECKED the View user information permission for all roles. ...
-1
votes
1answer
638 views

Alter views exposed form [closed]

I have a view that in that view I set up 3 exposed filter, all working fine. I need to set a condition to show the third filter option to a specific user, it can be checked according to the user role,...
0
votes
1answer
521 views

Is there a twig filter for mobile devices?

I would like to present the user with an image if they're on a mobile device but a video clip otherwise. I have used browscap in D7 but wondered if there's something more built-in to twig templates ...
2
votes
3answers
347 views

Hide a region with empty view in it

I have a region page_intro where I display a view, with some CSS on it. When the view is empty (return no result), the region is still displayed (All html code before and after {{ page.page_intro }}). ...
-2
votes
1answer
72 views

Module accidentally removed [duplicate]

Somehow, I accidentally deleted the shield folder after installing the Shield module, and now I can't disable it. I can't work on my site. Can anyone please tell me how to disable the module?
0
votes
0answers
24 views

Divide menu tree parents and children links into columns

I have the following menu tree for my main navigation: Parent 1 (= level 0) SubParent 1 (= level 1) SubChild 1.1 (= level 1) SubChild 1.2 (= level 1) SubChild 1.3 (= level 1) SubSubParent 1 (= ...
2
votes
2answers
4k views

How can I stop JavaScript from being cached during development?

I have a Drupal 8.00-beta11 site and am trying to dynamically add JS to a page, so that I don't have to clear the cache every time I edit the JS file. I have a custom module (lets call it my_module) ...
1
vote
1answer
428 views

Join user to custom table

I have a custom table (myusersession) which contains the uid field that is a reference to user entities. How can I add user entity fields (exactly 'name') to my view? I tried many variations of join,...
5
votes
1answer
6k views

How to create a “read more” button using AJAX in a module?

I'm working on a really simple module in Drupal 8 to get the hang of things. What it does (or rather, what the page I'm asking about in this question does) is grab some data of a bunch of simple ...
0
votes
0answers
18 views

AJAX View not working with Webpack

I have a Drupal 8 website running in a Docker environment. I have an AJAX-enabled View that works perfectly fine when I am running my website on the URL provided by my Docker setup (http://back.d8....
0
votes
1answer
527 views

where are menu item configurations stored?

In drupal 8, which file holds the information of the menu items? I do a config-export and do not see which file is changed when I change the menu items.
0
votes
1answer
407 views

How to export a menu and blocks?

I created a Superfish menu in a test installation of Drupal (8.5.4) and want to import it into another install (8.5.5). How can I do this? Is the navigation data stored in menu_link, ...
0
votes
1answer
1k views

How to add active class to title which is loaded via views in block

I have created content type XXX, via views I collected all titles of XXX content. That all titles works as links, I want to add active class to title which was clicked in block. It should works as ...
0
votes
1answer
390 views

PUT request: http://example.com/endpoint/node/{X,Y,Z}

I've been using the Drupal basic services module with REST from quite some time now. I would like to know if this possible: PUT request: http://example.com/endpoint/node/{X,Y,Z} Basically, what ...
0
votes
0answers
25 views

Hide if source (computed token) field is empty

I am setting up an event registration for an existing D8 website. I have added content type Event with fields start date, end date etc. And I have a webform for event registration with computed token ...
-4
votes
0answers
22 views

Add N rows to a webform custom composite element table

I have a webform with a custom composite element that has the following fields item,quantity,po upload,order type,completion date of type text,number,file,select and date respectively. now in ...
0
votes
0answers
41 views

How do I synchronize 2 sites, one installed with Composer and one from downloaded zip?

I have two sites: one, local, installed with composer create-project drupal-composer/drupal-project:8.x-dev mysitelocal --stability dev --no-interaction another one, remote, installed from drupal-8.7....
0
votes
2answers
36 views

How can I move a node type's configuration into a custom module?

I still a bit new to D8 and loving the new configuration management system that has replaced Features. I am looking for the best technique for containing particular configurations in my custom ...
18
votes
8answers
17k views

How do you implement a breadcrumb?

I've tried to define a new breadcrumb override, but I'm still getting the site default. I've created a custom module, foo_breadcrumb: - modules/custom/foo_breadcrumb - foo_breadcrumb.info....
2
votes
2answers
548 views

How to load a entity or node in form builder class?

I want to load default values in my form. I am fetching the node of the table row from form list and passing it into route. my_form_eform: path: '/edit/{bar}' options: parameters: bar: type: ...
4
votes
1answer
1k views

EntityQuery with a condition on an array

I try to list all fields where a paragraph type is referenced (to find all contents which have paragraphs of a specific type). My problem: I do a EntityQuery on field_config entity type to find the ...
1
vote
1answer
408 views

Geofield Map - Filter attachment result by clicking marker

I'm facing a problem with geofield map and I can't find a solution. So I have a view with a geofield map format. There I show all nodes from one node type as markers. Under my map I have an ...
6
votes
1answer
923 views

Are configurations written and read directly to/from .yaml files or still to the database?

Background Drupal 7 and previous versions have attracted criticism for Drupal web site admin configuration being stored in the MySQL database, the criticism being that being in a database means that ...
0
votes
0answers
29 views

Running ajax callbacks on custom composite field

I am using a custom composite field("test") in drupal8 webform in a webform_form_alter() hook. Two select fields-"out_part" and "out_serial" are added to this composite field("test"). "out_serial" is ...
2
votes
1answer
41 views

How can I determine in the body of a hook implementation what hook it is implementing?

I have a functional understanding of what the hook system is and how to use it in Drupal, but would like to deepen my knowledge. Normally when writing a hook, I know exactly what hook I'm using, ...
0
votes
0answers
20 views

Programmatically change exposed filter's operator

I'm modifying an exposed filter using a hook_form_alter to make it a <select> of type "multiple." This works great until I select more than one <option> because the original filter in the ...
7
votes
1answer
1k views

What changed in the way to implement a block?

The documentation for Drupal 8 lists the following hooks as the ones necessary to implement a block. hook_block_access() controls which users have access to a block hook_block_view_alter() is used to ...
0
votes
0answers
15 views

Getting error of “entity_share_client.commands”

While trying to update Drupal core I was facing issue with error - drupal/entity_share 1.x-dev requires drupal/jsonapi >=1.0.0 <2.0.0 But updating version of drupal/entity_share to latest ...