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
6
votes
1answer
1k views
+50

How do I translate theme settings?

How do you translate custom theme settings in Drupal 8? I use hook_form_system_theme_settings_alter to add custom settings to a theme. One setting is the text string (e.g. 'Menu') to display beside ...
0
votes
1answer
20 views

One field (entity reference - paragraph) with two display modes

I am having issue with displaying one field twice in my template having different display modes. I have a content type basic page with field field_gallery (which is entity reference on paragraph). In ...
-4
votes
0answers
17 views

Cannot change node url value [on hold]

I am using drupal 8 and php 7.2 in windows 7 How can I change or replace url value in node field ?
1
vote
1answer
344 views

How to get parent node values on inline entity form hook alter?

I am using inline entity forms to create a paragraph in a node form. When I add a node I want the title of the node form to be copied to the paragraph when I click on "Add paragraph". I use ...
1
vote
3answers
1k views

How to disable Toolbar on certain pages / theme?

Before deprecation of hook_page_build/hook_page_build_alter() we used good old method: $page['page_top']['toolbar']['#access'] = FALSE; (Source) It disabled Toolbar for specific route in specific ...
0
votes
1answer
17 views

How to add extra eventlistener to menu object in attached library

This is my first Drupal 8 project and I'm running into a problem figuring out how to attach an extra event handler to an object. I am working on a custom theme using Radix as base theme. I am using ...
0
votes
1answer
477 views

Migration of CSV into paragraphs fails with unexpected error

I try to import CSV files into a Drupal 8 installation but I can't manage to make the relationship to paragraphs appear. I followed the steps of this tutorial but can't figure out how to make it work. ...
2
votes
1answer
54 views

Variables injected or set in a Twig file are undefined after the first position of an entity reference field

I have a Paragraph setup that has an entity reference field allowing an editor to select multiple nodes to use in a display. Based on the count of nodes, I want to trigger a class. I figured a way to ...
0
votes
0answers
6 views

Retrieve last published (moderation state) version of node when transitioning to published

I'm wanting to get the last published revision of a node that has a content moderation state of "published". The below code works fine until I set a node to the "published" state at which point it ...
1
vote
1answer
336 views

Get array length of a multiple fields of a node content type

I'm developing a site with Drupal 8. I made a custom content type, with a lot of fields; in particular I have a field called field_categoria_del_libro_presen that is linked to a taxonomy term. It's ...
5
votes
2answers
3k views

How do I load a form with a specific form display (form mode)?

On a custom page I'm trying to load an user edit form with a specific form display. I'm able to load the form however I can't figure out how to load the form with the specific display. This is what I ...
1
vote
4answers
337 views

Simple way to add a class to the body when creating/editing an entity

In Drupal 8.4, I am trying to add a class to the body (like Drupal 7 had) when the page viewed is a node (or entity for that matter), something like [entity]-[create or edit], so that, when a user is ...
0
votes
1answer
16 views

Block email from submitting webforms

I have a list of email addresses that I would like not be able to submit in webforms. I can't seem to find a setting for this? Is this currently possible or do I need to make a custom module to ...
3
votes
4answers
3k views

Modal Dialog not Opening when not authenticated or in incognito mode

Hi i am using Drupal 8 to render a modal popup on clicking a link. However when i am connected as admin the popup render well but as soon as i logout or choose to be incognito mode of the browser the ...
0
votes
0answers
12 views

Poll module alternative / node integration

I just added the Drupal 8 Poll module and can't seem to get it working in a content node by entity reference - rendered entity. It shows nothing, not even a field. Perhaps I'm missing something?
1
vote
1answer
267 views

How do I alter images being added via IMCE CKEditor plugin?

I just wanted to share my solution since I did not find any clue or different way of fixing the following problem: Formerly, you could add a default class/ alter attributes of newly inserted images (...
0
votes
0answers
13 views

How to add a pager to the TOP of a forum in Drupal 8?

I am using the standard forum module that comes with Drupal 8. The problem is, when I view a forum node, it shows the pager the bottom. I want the pager to also appear at the top. The closest I've ...
0
votes
1answer
405 views

Images uploaded with CKeditor disappear after cron run

When i upload images with CKeditor in a directory inline-images - they disappear after each cron run. Why is that happened? I had a look at db table file_managed it's status set to 0. What it might ...
0
votes
1answer
15 views

How to include a patch to a JS library?

I'm using the Superfish library in my Drupal 8.7.x project. I included it in composer.json like this: "repositories": [ { "type": "composer", "url": "https://packages....
0
votes
2answers
339 views

Use twig to style a specific block (unformated list)

I have a block showing a unformated List of fields. Now I would like to use twig to style that block. I am able to use block--views-block--blockname-block.html.twig to do the outer styling. But I ...
0
votes
2answers
455 views

How to specify the correct private file path in a block

I have a Drupal site at http://example.org/xyz Per the instructions here, I have set up a private file directory outside the web root. So let's say the web root is at /home/public_html/example/xyz ...
27
votes
11answers
54k views

“The website encountered an unexpected error. Please try again later.”

I have this error with Drupal 7 how can I have some more information about this error ? Any report, any log anywhere ? Nothing in php errors. how can I disable that message and have a more useful ...
0
votes
1answer
424 views

Get Checkbox Value From Another Form

How do i get the value of a checkbox from another form/page and how do i make it so if the checkbox is enabled, it'll allow a button to be visible? checkbox in SettingsForm.php: $form['#tree'] = ...
0
votes
1answer
39 views

How is the user logout process supposed to work?

I’ve built a complete private site. Everything seems to work. When users wants to log out, they are redirect from /user/logout /user/login?destination=/, which seems the normal behavior, for what I ...
2
votes
1answer
2k views

Updating core to a specific version with Composer

My site hasn't been updated for two months, a few new updates has been released. My site's core version is 8.5.6. Before running composer update -with-dependencies I read the release notes to the ...
1
vote
1answer
393 views

How to have a field displayed depending on user's role in Views?

I use Views module to display the content of a custom entity with Page view (not Block view). I'd like to have one field displayed only if the user has a certain role. What is the best way to do that?
1
vote
1answer
339 views

Use MenulinkTree::load in page_preprocess

I'm on drupal 8, and i want to get menu links from the main menu in order to create the same menu for mobile (so i need 2 same menu, with differents rendering) I use like this : function ...
0
votes
1answer
20 views

Hook to run afer config import

I need to run some code after the config for my module is imported(it will create/update a css file that depends on configuration). So what is the correct hook to use? The module install will run only ...
2
votes
3answers
1k views

Include external JS/CSS libraries in a module?

What is the Drupal 8 equivalent of including external libraries (like sites/all/libraries) for custom modules?
1
vote
2answers
346 views

Block cache depending on current node and its last modification time

I am building a module with a block that outputs some informations from the current node. When i return my render array i managed to get the cache as "node dependent" using (maybe not the best method ...
3
votes
3answers
2k views

Difference between drupal_static and \Drupal::state?

Imagine I have a hard-to-compute value. $my_heavy_value = compute_heavy_value(); What's the difference, at performance level, between storing the computed value using drupal_static() and using \...
0
votes
2answers
524 views

Media theme missing from the file system?

Not really sure about this error, I wasn't aware there was a media theme but could anyone help me understand this please? User warning: The following theme is missing from the file system: media in ...
2
votes
1answer
374 views

Third party library added via composer.json but how can I load it in a module now?

I have set up a module in my Drupal 8 project to handle some tasks I need doing using AWS. I added the awssdk (for PHP) to my composer.json and ran the composer update command successfully. the AWS ...
1
vote
2answers
1k views

How do I use $form_state['storage']['my_key']?

The question is clear from the title itself . I looked in the api specified in : https://www.drupal.org/node/2310411 . But it only mention to convert $storage = &$form_state['storage']; $...
0
votes
1answer
435 views

Request referer gets cached

I need to grab referer and save it for the first time (I save it to sessions) and when the user gets to a specific page forward it. My problem is that after opening page with the same referer few ...
1
vote
1answer
53 views

How to get entity Translation's title in Twig

i am trying to get row title -node title- in my custom module with template_preprocess_modulename_view($variables) and views-modulename-view.html.twig with using row.content['#row']._entity.title....
0
votes
1answer
103 views

Why does d7_user_role need a db connection configured when migration group already defines it

I've just done a super basic user_role import and I'm trying to do a user import. Both are in the same migration group and the migration group has a souce key to specify which db listed in settings....
0
votes
2answers
494 views

Remove comment link from node teaser

I want to remove comment link (actually it is li element) from node teaser view on homepage and term listing. I want ways to do in controller/service or in template or if possible in admin. I have ...
0
votes
1answer
39 views

Change view mode based on the URL

I have nodes whose content type is X that I would like to render differently based on the node path. I'd like to use the default view mode for a path alias and a custom view mode for the other path ...
0
votes
0answers
23 views

Enable translation for theme settings

Theme settings are not translatable in core. Is there a way to make them translatable? I have some additional theme settings which needs to have different values per language. I'm trying to achieve ...
0
votes
2answers
392 views

How to change the field format in a view?

My view (page display) has few fields and I want to change one field's format to html. How can I do it programmatically by using hook_views_pre_render() or perhaps any other hook_?
0
votes
1answer
17 views

REST Export Serializer adds quotation marks to my field

I'm using the REST export to expose a list of my nodes including some fields. One of the fields is paragraphs field with subfields. I have written a formatter for this paragraphs field that puts ...
0
votes
0answers
30 views

Hook “form_views_exposed_form_alter” is called multiply times

I would like to understand why form_views_exposed_form_alter is called multiply times. There is just one view, also there is just one exposed filter. However the hook is getting called twice. ...
0
votes
1answer
30 views

Is it possible to show a menu in a view as buttons?

I'm trying to build a page with a quick menu. Now I've created a menu by the regular way and I've shown this on the place i wanted. Now due to the way my site currently looks, this is very out of the ...
1
vote
1answer
353 views

How to sort the query results?

In my task I need to display the results based on "the newest first". I perform a query: $query = \Drupal::database()->select('node_field_data', 'node'); $query->innerJoin('...
0
votes
0answers
15 views

Programmatically update remote video thumbnail

Scenario: YouTube video was previously unlisted, so thumbnail not retrieved and now needs to be, or chosen thumbnail has been changed and needs updating. There are a couple of core issues open on ...
0
votes
2answers
62 views

wrong translation in admin/structure/views

I have a multi language site with Drupal 8.7.4 and default language is English. when i go to en/admin/structure/views i see list of views in English language. if i go to french interface via fr/admin/...
-3
votes
0answers
12 views

I can't upload user picture [on hold]

I want to upload an image for a simply user on the default form and I get the following error : "The file could not be uploaded." I have tried with all types of file formats. I also checked the ...
2
votes
1answer
516 views

Can I have both Language and Country path prefixes?

On our site, paths are all prefixed by language and country. For example: http://example.com/en/us/about In Drupal 7, a previous vendor implemented this by using the Persistent URL module, which ...
0
votes
1answer
41 views

Custom formatter for paragraphs field

I want to build a custom formatter for a paragraphs field that renders some of the fields of the paragraph. However, I don't know how to access the single files of the paragraph field. So far I've ...