Skip to main content

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

How do I get a URL variable in a template?

I am trying to include a certain .html file if the URL has ?work=1. So far I have this, which I got from Check URL for string in a Twig file. {% if 'work' in url %} {{ include('work/index.html'...
1 vote
1 answer
524 views

I can't get the correct current language in node URLs

In D8, I have a website set up with 5 languages, using file path, like so: website.com/en/link website.com/en-us/link website.com/fr-ca/link etcetera. I've made a view of blogs and resources. It ...
1 vote
1 answer
768 views

Getting 400 Error as A client error happened

On our multi-site platform using Drupal 8 hosted on acquia we are getting 400 error response on all the hosted websites The error is not persistent but only occurs when user comes through a referrer ...
1 vote
2 answers
4k views

"Uncaught TypeError: Cannot read property 'getAttribute' of undefined"

There are some posts about this error for Drupal 7, but I'm using Drupal 8.1 and those solutions don't work for D8. I tried this patch (coded for D7) and doesn't work. The effect of the error is ...
0 votes
1 answer
557 views

Scheduler Module unpublish content

Trying to schedule a content type to be unpublished on a specific date. Using the scheduler module everything is set up seemingly correct. When I run Cron the update fails, Updater Content - ...
0 votes
1 answer
679 views

Get Role Label instead of Machine Name

I want to know how to show role label in twig view. I have this {% set roles = user.getroles(TRUE) %} {{ dump(roles) }} It's giving me my role, but instead of showing "Directeur (CR)", it's ...
3 votes
1 answer
1k views

Why do I get an error about the extension.list.module service non existing?

I installed Drupal 8.5.6 and Drupal Commerce with Composer. They installed fine, but after I cleared the cache, I got this exception in a WSOD. Uncaught PHP Exception Symfony\Component\...
0 votes
1 answer
1k 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 ...
0 votes
1 answer
395 views

How to add programmatically region's class when region had block?

I have one row with three column region. How can I add a custom class on each region when one of region is not used? With three regions, the class is col-sm-4; with two regions, the class is col-sm-6; ...
0 votes
1 answer
522 views

how to test if a node is flagged in twig

I would like to know how to test if a node is flagged. In D7 : if ($ flag-> is_flagged ($ node-> nid)) But I discover D8 and I do not see how to do it with twig thank you in advance
0 votes
1 answer
506 views

Hiding menu item depending on specific access

I work on a D8 (8.6) I want to hide some item on my menu depending on route param onto this link. When I try to access the route I get a 403 error and works as expected but the the link inside the ...
0 votes
1 answer
1k views

How to override Breadcrumb theme template?

I have a custom theme that has base theme: classy setting in the mytheme.info.yml file. When we enable twig debugging locally, we find that the <!-- BEGIN OUTPUT from 'themes/custom/mytheme/...
0 votes
1 answer
459 views

Exporting Custom Menu Translation

Question: How do I export/import translation of Custom Menu Items I have a module that takes all the .po files for custom strings and then uses locale to batch import them. This works great. I was ...
0 votes
1 answer
470 views

Why do I get a page content instead of a redirect?

I have to send a request to an external API which returns a redirection link, using the following code. try { $response = \Drupal::httpClient()->get($url, ['headers' => ['Accept' => 'text/...
2 votes
2 answers
2k views

TypeError on "drush config-export"

I've been receiving the following error message when trying to do a drush config-export command. However, I am able to successfully do the configuration export from the Drupal admin page (admin/config/...
22 votes
6 answers
30k views

Site UUID in source storage does not match the target storage

When I run drush cim -y on my staging instance of my site I get the following error: Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization. in Drupal\...
1 vote
1 answer
581 views

Why doesn't my custom OutboundPathProcessorInterface work anymore?

I wrote my own implementation of OutboundPathProcessorInterface to rewrite the URL of nodes to use the content of their field_project_url field. namespace Drupal\mymodule\PathProcessor; use Drupal\...
0 votes
1 answer
1k views

Issues trying to understand and debug simplesamlphp error

Simplesamlphp used to work on the site. Something changed and now it does not. The IDP remote config has been verified, including the cert The SP cert and pem in the simplesamlphp/config folder have ...
0 votes
1 answer
510 views

Using entity_lookup inside an entity_generate migration process plugins

I'm trying to use an entity_lookup process plugin inside an entity_generate process plugin. The YML looks like this field_validation: plugin: entity_generate access_check: false ...
2 votes
1 answer
1k views

How to handle session for anonymous users for CSRF tokens?

I need to provide a list of CSRF tokens in drupalSettings for every anonymous user to make safe requests to API endpoints. The CSRF service mentions the need for session to exist for the seed, but I ...
0 votes
1 answer
867 views

How to configure chosen on Form API with an entity_automcomplete widget?

How to configure chosen field on Form API with drupal 8. I have already installed chosen and it's works in User Interface and not in form API. This peace of code doesn't work: $form['tags']...
3 votes
1 answer
643 views

Is there a way to add node grants to anonymous users?

I want anonymous users to be able to access nodes that are promoted to the front page. (They can't access to nodes that are not promoted.) It seems hook_node_access() isn't seem called for anonymous ...
0 votes
1 answer
2k views

How to identify item_selector for Migrate API JSON imports

Trying to import articles from an external JSON feed of "members" with a structure like this: { "status":"OK", "results":[ { "num_results": 10, "offset": 0, "...
1 vote
1 answer
994 views

Search API autocomplete group suggestions

I am using Search API, Search API autocomplete and Solr search. I'we made a view with an exposed filer that has a funcionality of search api autocomplete. For now, autocomplete suggestions are just ...
0 votes
1 answer
2k views

How do I check radio buttons in Twig template?

In a form, I have this field: $form['payment'] = [ '#type' => 'radios', '#title' => $this->t('Payment Mode'), '#options' => [ 'chk' => $this->t('by check'), 'tfr' =&...
8 votes
2 answers
5k views

Migrate address field

I am currently searching for a example to migrate data into an address field in Drupal 8 without any luck for now. Has someone a hint for me on how to map the fields? I tried the following: my....
2 votes
1 answer
550 views

Alter existing 'Log In' route so URL includes request_uri as query string

I am trying to alter the existing 'Log In' URL so that it points to a certain location and also includes the REQUEST_URI as a query string that is not encoded. How do I do this? Based on this article,...
0 votes
1 answer
1k views

REST API Guzzle POST gives timeout but the same call works if I run it on the server cli

I have Drupal running in a docker container and nginx running in another container. When I do the login call through postman or directly on the webserver cli it works perfectly. But when I do call ...
0 votes
2 answers
993 views

How can I rewrite the output of image field to become a div with this image as a background image?

I have a view to display a content that have an image field, and I need to display this image as a background image of a div so I can apply some CSS on it. what I tried to do is to rewrite the output ...
4 votes
3 answers
3k views

How to re-index all content for the core search engine?

Is there a way to re-index all content for the core search engine? In older versions, you could reindex with drush: drush search-reindex --immediate --verbose However, this does not appear to be an ...
1 vote
1 answer
701 views

Why is the login redirecting to the access denied page?

This question has been asked before but I see only D7 versions of the question, and none of their answers have helped me in D8. I log in perfectly fine with Chrome or Firefox, but IE 11 redirects to ...
2 votes
2 answers
1k 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 perfectly. Kudos to the Drupal console guys. ...
0 votes
1 answer
391 views

How can I print the file size and other file info in a Views field template?

I have created a content type with a number of fields including file fields. In the node template for that CT (node--unit.html.twig) I am able to get the details with the following code: {% if ...
2 votes
2 answers
1k views

How to translate the language switcher links

In Drupal 8.1 the language switcher (block can be placed in a region) shows the languages labels in English: English | German | French I want to translate it. Visiting mysite/de the label should be ...
0 votes
1 answer
502 views

Is there a way to change how a form button looks?

I know how to add a class to a form element and how to add a form submission button, but there are classes that are automatically added to these buttons in my Drupal 8 install. The form I am editing ...
38 votes
12 answers
60k views

How can I change the page title?

In Drupal 7, I could change the page title with drupal_set_title(t('New page title')). When I try it in Drupal 8, I get a There is no such function error. How can I change the page title?
3 votes
5 answers
7k views

How do I programmatically set the view title?

In D8, I have a need to dynamically set the title of a views page display. I've tried implementing both hook_views_pre_render and hook_views_post_build and setting the value of $view->build_info['...
0 votes
4 answers
1k views

How do I add HTML markup to the title?

I am trying to alter my title to include html. I have tried the following function MODULENAME_views_pre_render(\Drupal\views\ViewExecutable $view) { if ($view->id() == 'products_test') { ...
0 votes
1 answer
2k views

Edit CKEditor's config programmatically

I've created a Drupal 8 module that adds a custom plugin to the core's CKEditor. This plugin allows users to add tabbed content to their pages. The problem is that the plugin adds a class to the ...
2 votes
1 answer
944 views

cannot use some drush commands

I am running into some trouble with drush pm-enable: I cannot enable the modules I just downloaded. I did some research but none of the solution worked for me, most cases involved switching localhost ...
1 vote
1 answer
2k views

Views escapes HTML tags in node body

I'm creating a view that displays a few fields from a specific content type. Among the fields is the trimmed nody body. The problem is that the HTML tags in the body are escaped and are visible as ...
0 votes
2 answers
423 views

How do I add a region to the Color module?

I have a menu I would like to be able to style with the Color module. I have found many examples for the Drupal 7 Color module and they have led me to believe that if I just add a line to the 'fields'...
1 vote
1 answer
417 views

How to override a function inside of a Trait?

My goal is to override the function isApprovalRequired() in a Trait for the module Social Auth (social_auth). The file: modules/contrib/social_auth/src/SettingsTrait.php has a function (along with ...
3 votes
1 answer
788 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 ...
2 votes
2 answers
1k views

Creating 2 forms to work together on the same page for the same query

I'm facing trouble coming up with the following approach: I will have 3 separate forms acting on the same query from third party API's. On the front page there is a shorter quick-form that would ...
0 votes
1 answer
1k views

hook_views_query_alter() not working?

Very new to web development and even newer to Drupal, and I have some questions that I would really appreciate if anyone could answer! Here's my yml file, [Site name] is actually just the name of our ...
0 votes
1 answer
2k views

Rewrite markup of a field in twig template

I want to calculate dynamical a value and give it back in the markup without saving the newValue. I try this with: {% set content.field_my_field[0]['#markup'] = newValue %} This doesn`t work! The "...
0 votes
1 answer
754 views

Geolocation and view proximity filter - Can you default proximity to zero?

I'm trying to see if there is a way to default the views proximity filter to input zero for proximity values when the filter is empty, so we can sort the data using a different field by default. What ...
1 vote
1 answer
559 views

How can I enable search on parts of a word and autocomplete suggestions?

I'm using Search API in Drupal 8. I tried with Search API pages and even views, but I didn't find %like% function query Can I do %like% in Search API or Views?
0 votes
1 answer
452 views

Search Api display search term in form

How do I display the search term after I have run the search. Here is my form: <input data-drupal-selector="edit-search-api-fulltext" id="edit-search-api-fulltext" placeholder=&...

1
2 3 4 5
316