Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
3 views

How to migrate file uploads from Drupal 6 to 8?

I'm working on a custom migration from Drupal 6 to Drupal 8. Some of the content types have a field used for file attachments. In Drupal 8 this field has the internal name field_attachments. When I ...
1
vote
0answers
5 views

8: Datetime field show different format browser wise

I have tried https://www.drupal.org/project/webform/issues/2990482 https://www.drupal.org/project/drupal/issues/2791693 For Drupal 8.6.3, but it's not working.
0
votes
1answer
34 views

How to access all the parameters in URL without getting a “page not found” error? [on hold]

I used this code in Drupal 7 can access all parameter. Example: $items['hello'] = array( 'page callback' => 'hello_handler', 'title' => 'Hello page', '...
0
votes
1answer
643 views

Theming custom block type have multiple paragraph field

I've created a custom block type includes a paragraph type field and make it multiple. I've configured this block to display it only on the front page. I have a page--front.html.twig template in my ...
0
votes
1answer
4 views

Excluding inline images in views

I have a node type with an image field and insert button to get the image into the text field. Then there is a view that is getting the content of the text field and shortening it to 150 characters. ...
2
votes
2answers
459 views

How to make a theme hook suggestion for menu according to region?

I'm placing the same menu block in two different regions whereas different html markup for the list is needed. So analog to my previous question "How to make a theme hook suggestion for blocks ...
0
votes
0answers
5 views

loop through paragraphs ID's in node template

In a custom twig template for content type "legal", I'm trying to loop through a 3-field paragraph called "legal_section." It's referenced by my content type, using an entity reference field called "...
19
votes
6answers
20k views

How do I render a form?

What is the alternative to drupal_get_form('user_login'). in Drupal 8? I am using the following code in theme_name.theme, but it doesn't work. // Include namespace for userLoginForm. use \Drupal\...
0
votes
1answer
11 views

How to add the view name as body class

function THEMENAME_preprocess_views_view(&$variables){ $view = $variables['view']; if($view->name == "YOUR_VIEW_NAME" && $view->current_display == "MACHINE_NAME_OF_VIEW"...
0
votes
1answer
19 views

Hook for Node Add Field?

For my use case, this question revolves around the entities node and paragraph. Fields in my projects are created under the following structure: content_h2 paragraph_h2 content_p paragraph_p ... ...
0
votes
1answer
17 views

How to show contextual links / quick edit links for blocks

I'm building a Drupal 8 template/theme from scratch, and it is not showing the contextual editing options for my blocks when I view a site page. I.E., the little circles that are clicked to see ...
0
votes
1answer
10 views

Override view-list and get items properties

I'm currently working on Bartik theme and i'm trying to create a custom template for the Content-Recent block available in Drupal 8 For your information, i would like to create the following block ...
0
votes
0answers
16 views

View filter settings not selected properly in production environment

I have a group of block views for various program pages on my site which have a filter for an area of interest. Within my "Area of Interest" taxonomy term are numerous areas for the different groups. ...
1
vote
1answer
33 views

Why return AccessResult::allowed() ends up with “Access denied”?

I'm having a strange behaviour while trying to use hook_node_access in Drupal 8 (Lightning to be more precise) and I can't figure out why is doing this. Let's suppose that I want to always allow ...
0
votes
1answer
66 views

Is there a better way to style fields?

I'm learning twig and using it to format and style my fields. The problem I am running into is that I need to create a new twig template for each individual field. In the example picture, I have ...
2
votes
1answer
2k views

How to use composer for installation profile?

I have a Drupal 8 installation profile with custom modules and themes and I am wondering how should I use composer so that I can run it and drupal core and other dependencies(like contrib modules) ...
1
vote
0answers
21 views

kint() my_theme_preprocess_node error [on hold]

After using kint in my 'mytheme'.theme file to output the variables : function my_theme_preprocess_node(&$variables){ kint($variables); } I get the following error: RuntimeException: Failed ...
2
votes
2answers
117 views
+100

Delete a block of all layouts

I am using Layout Builder (Drupal 8.7.1) I have a block in several Layouts. How can I programmatically remove all instances of this block and update all layouts without the message "This block is ...
0
votes
1answer
127 views

How to add css files based on breakpoint in library?

We have the following mytheme.breakpoints.yml file and a simple library mylibrary that is added through our mytheme. Within the mylibrary there are two libraries, one that is optimized for desktop ...
1
vote
1answer
346 views

Content edit links?

I'm new to Drupal 8 and can't figure out a way to show the edit contextual links for content displayed through the Views module. This was simple in Drupal 7, but in Drupal 8, a view only shows the ...
0
votes
1answer
24 views

ThemeNegotiator not working for admin pages

I'm trying to use the ThemeNegotiator to change the theme of the add and edit pages of one content type. I've followed the following very extensive posts/blogs. Don't use admin theme for adding ...
1
vote
3answers
7k views

How to check a boolean value in twig templates?

We have a field_boolean (boolean field) on an ECK Bundle on the article content type. While doing research we came across this question, but does not solve my problem. What is the appropriate way to ...
0
votes
1answer
32 views

How can I add folders to my template directory and have Twig find them?

I was listening to a Drupal Developer on youtube and one of the suggestions he has, is that when you go into a template folder, create some subdirectories for easier management, like this: Templates -...
0
votes
2answers
343 views

Override theme function inside module, template_preprocess_field

I'd like to implement template_preprocess_field in a module for organizational purposes. How can I do this? Thanks! Reference: https://api.drupal.org/api/drupal/core%21includes%21theme.inc/function/...
2
votes
1answer
42 views

Twig whitespace controls have no effect on fields

I am trying to iterate over a Paragraph field and apply a comma after each Paragraph item. In the field template that outputs the Paragraph, I am trying: {%- for item in items %} {{ item.content }}...
0
votes
1answer
24 views

Using ImageStyle with dependency injection

Is there a way to use the ImageStyle class with dependency injection instead of a static call? I am struggling to find an example. At the moment I have a block which is importing the class with ...
-3
votes
1answer
57 views

Use a Twig filter to resize / crop images in templates

I want to use a twig filter to resize/crop images in templates for responsive images, I know I can generate responsive images with Image Style and Responsive Image styles, but that requires too much ...
1
vote
2answers
581 views

File Upload Field not working

I just tried to create a simple mandatory file upload field in a custom form like this: public function buildForm(array $form, FormStateInterface $form_state) { $form['#attributes'] = array('...
0
votes
1answer
24 views

How to print the URL path of a referenced node using paragraphs?

I'm trying to print out the url path of a node from a referenced entity paragraph field in my twig template however have not had any success so far. I have tried various common twig functions but with ...
0
votes
0answers
38 views

How do you get and submit a webform in React?

I am planning to build a Drupal 8 site fully decoupled using Gatsby (a site generator for React). So I will use Drupal only to structure (content types, paragraphs), enter and update all the content ...
0
votes
0answers
12 views

Automatically add meta tags on node creation

I'm currently maintaining a lot of different sites containing the same information pages (example: profile pages with the same content but on different sites/base URL) and I'd like to consolidate this ...
1
vote
1answer
39 views

How to use hook_prepare to modify a field of a node before it is edited

I want to modify the contents of a field of an Article node just before it comes up for editing. I have read the documentation at http://api.hostdog.gr/api/drupal-8/drupal%21core%21modules%21node%...
1
vote
0answers
50 views

Use generated JWT to authenticate user in Drupal using REST API [closed]

We are working on developing a mobile app and users should be able to log in to the app and in our backend Drupal site authenticated from Keycloak. Our main goal is that the user would be able to ...
0
votes
0answers
11 views

Subrequests: Assigning Paragraphs entity to node

Migrating a content type from D7 into a greenfield D8 app, so I'm using Subrequests and jsonapi modules. My first subrequest to create a simple Paragraph returns the new ID and it properly replaces my ...
1
vote
2answers
612 views

Load all/multiple fields from entity of certain type

I'm quite new to drupal so bear with me here. I've created an entity using Drupal Console, specifically using drupal generate:entity:content. Which works perfect. Kudos to the drupal console guys. ...
0
votes
0answers
21 views

Provide autocomplete field with user's Display Name

Drupal core already supports autocompletion of username fields. However is there a way to provide autocomplete for user's Display Name? Since this is a virtual field, a database query with % like ...
0
votes
1answer
757 views

How do I create a configuration sync folder?

I've inherited a Drupal 8 site but it has no config_HASH folder with it which means that the majority of admin paths throw an exception. How do I generate a new configuration folder based on the ...
0
votes
1answer
660 views

How do I reference an image inside my custom module directory?

I want to ship a default image in my custom module. I know I can reference images in the files directory with public://, but how can I properly reference my module's URL path? Update: I need to pass ...
0
votes
0answers
21 views

Render content type display mode in custom module [duplicate]

I'm facing the issue with rendering content type in specified display mode (teaser) in my custom module. I have a module which stores NIDs in session, and when user enters specific page, I want to ...
0
votes
1answer
586 views

How to change background image based on current node?

I am trying to change the header background image of my website based on the current node. I have added an image field to my content type, field_hero_image, and, in preprocess function ...
1
vote
1answer
40 views

In code, only create a revision if a field is changed

I have a custom revisionable entity with a few dozen fields. I'm importing data about the entity on a periodic basis. If the entity has changed, I'd like to save it and create a new revision. $dogs =...
0
votes
0answers
46 views

How to stop a local database from launching the online website?

I'm a designer and new to Drupal. been studying for a couple of months creating sites for personal learning. I started working in a company that had a Drupal 7 website. I studied, learned it and ...
0
votes
2answers
354 views

Default user image in user account menu!

I am trying to add a default image to render in the user account menu when the user does not have an image. CODE: function nestle_preprocess_menu(&$variables) { if($variables['menu_name'] == "...
0
votes
0answers
45 views

How do I differentiate between different node dates?

A site owner wants to differentiate between semantically different dates of articles published on their Drupal site as follows: Editorial changes on an article will NOT create a new revision. Content ...
0
votes
1answer
598 views

can I generate a user login form twig file

So I want to create a separate user login page for my website. I create a twig file called page--user--login.html.twig which is great for the outer container. I still want to edit the form divand or ...
1
vote
1answer
243 views

Aggregator with custom RSS field

I have a simple RSS feed I am importing via core Aggregator module in Drupal 8.5. One specific field in the Item can't be accessed by Views, and it's critical for display. I'm relying on hacky ...
0
votes
1answer
26 views

How to print the URL of a title field?

I'm trying to print out the url path from the title in my twig template however I haven't been successful so far. Printing out the title containing the link works fine using: {{content.title}} ...
0
votes
1answer
674 views

View block pager not working

I have the following view what also is rendered as a block. This view has a mini pager with default 3 items to show. When i check configuration of the block of this view it looks like this : I ...
0
votes
1answer
620 views

token_filter module: [node:nid] for custom block?

Drupal: 8.1.7 Module: token_filter 8.x-1.0-beta1 I have a custom block with a Text format that has Global and entity tokens are replaced with their values enabled. The custom block has this value: ...
2
votes
1answer
2k views

How can I specify inner elements template in custom login page?

I am new in Drupal 8. I want to create a new theme to according to my HTML. What is the best practice to integrating a custom build theme to drupal engine. I have covered all sections in Drupal 8 ...