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
2 votes
1 answer
221 views

Features and CMI Together

We are developing a single Drupal 8 site with a set of different features (content types, etc). The CMI approach is great for sharing config through git and importing/exporting on local, dev, stage, ...
0 votes
1 answer
361 views

How to remove "Time Zone" element "user_register_form" form using hook_form_alter

I analyzed the "Create new account" page of drupal by using hook_form_alter and $form variable. as you see, #form_id value is: "user_register_form" and other elements are as following: attributes->...
1 vote
0 answers
491 views

Drupal 8 - Extend module controller

I want to extend PanelsIPEPageController but I have this error: [Tue Mar 07 09:48:26.308720 2017] [proxy_fcgi:error] [pid 1170:tid 140603094411008] [client 192.168.10.155:60806] AH01071: Got error '...
1 vote
1 answer
367 views

How to setup sitewide keyword search?

I am nearly finished with my website on Drupal 8, and one last thing I have to do is optimize the search function. At this moment the search function only searches for node titles. What I want to ...
4 votes
2 answers
2k views

Selecting taxonomy term in article and showing all articles titles associated with this term

I have a content type article and when editing an article there should be a field where you can select a taxonomy term of a specific vocabulary. When viewing the article it should show a list of ...
2 votes
2 answers
170 views

How do I show all "songs" that reference an "album" (for example)?

Suppose I have a content type (Song) which has a content reference field, referencing an Album node to which it belongs. When I view an album, I want to show a list of all songs which reference that ...
9 votes
2 answers
8k views

Get an image with style url from an URI in twig

So thanks to 4k4 I finally managed to get my original image URI in a field template via item.content['#item'].entity.uri.value and with {{ file_url(item.content['#item'].entity.uri.value) }} I ...
0 votes
1 answer
53 views

Resubmit all nodes

I would like to save all nodes, because I created a validation function picking data from Google Analytics. This doesn't work: $node = Node::load(nid); $node->save();
1 vote
1 answer
821 views

Programing date custom field into content type

I'm building a module that creates a content type when it installs. I already have my content type, let's call it MyContentType and I have a field body that I created based on Drupal documentation (...
1 vote
1 answer
81 views

Deploying to live and available modules

In Drupal 8 you can export configuration and move that to a production server. In core.extensions.yml there is an exported list of the enabled modules. If on development I have devel and other ...
2 votes
1 answer
73 views

How add custom node in a View (Nested View)?

Currently I have simple view that is used on the main page. In includes nodes of custom type. That's great. But now I need to do something different. Consider I have following structure: -----View---...
2 votes
1 answer
790 views

How do I get all the referenced taxonomy terms without the field name?

I have been looking into entityQuery but haven't seen what I am trying to do yet. If I have a node object, is it possible to get all taxonomy terms referenced by the node object, regardless of the ...
3 votes
1 answer
306 views

How to message or invite a group without joining it?

I'm using the Group module. I created a group(Job Post) with linked content types (Job details). Scenario: As a user, I created several jobs. I want to be able to invite/message another group (...
4 votes
1 answer
1k views

How would one upload a list of users via a .csv file and have them blocked by default?

The user import modules exists for Drupal 7, but how would one import a list of user from a csv file into Drupal 8? And once they are imported, have them blocked by default. Now when the users come ...
3 votes
2 answers
949 views

Restrict media files to other users once uploaded

I'm using Media Entity Browser to let users add new or existing media files in a content type. I have two groups. Business-A uploaded an image in a content. Business-A can re-use the image in writing ...
1 vote
0 answers
258 views

Trouble with Drupal 8 REST API and JavaScript client

I have created a Drupal 8 site and enabled REST on it. I can successfully preform requests against it using Postman or curl. However, when trying to perform those requests from a JavaScript ...
2 votes
2 answers
9k views

How to display language switcher block as buttons, instead of simple links?

the language switch block looks like this: I would like to display it as bootstrap buttons or whatever else is possible. At least not in plain links. <button type="button" class="btn btn-primary"&...
0 votes
1 answer
1k views

Show field from a join table on Views

Let's consider a views on an entity named :"Person" . "Person" has a field named "id" (the primary key) "PersonTag" has a field named "person_id" (this field is referencing the id of "PersonTag" ...
5 votes
1 answer
23k views

How can I run a database query in code? [closed]

I want something like SELECT nid FROM node WHERE type = "blablabla". How do I do this in Drupal 8 PHP code?
0 votes
1 answer
426 views

How to set custom user view mode for comments

How do I control which view mode of a user account appears on different pages? I have a Compact user view mode with two fields I want to appear in forum posts and comments. I then have a more ...
15 votes
3 answers
30k views

How do I access field data in Twig?

I have a list field for a custom block type that looks like this: left|Align left right|Align right I can access the key in Twig by doing something like this: {% block content %} {{ content....
2 votes
0 answers
386 views

How to display the "Add To Cart" button on a entity implementing the PurchasableEntityInterface?

The product entity than come with Drupal Commerce 2.0 don't feet my needs. Following the documentation, I made a custom entity that implement the PurchasableEntityInterface (Work in progress). But ...
1 vote
1 answer
923 views

Send data from controller to hook_form_alter()

I created a module for searching movies in different external databases. I use the Drupal node add page to handle the insertion of the movie. Now I need to know a way to send the data from my custom ...
0 votes
1 answer
29 views

Gettting errors after install drupal-8.2.6.nl.po

I add Language Dutch and import drupal-8.2.6.nl.po This error is showed on every page: sourcetext 'The file could not be created' What should I do? 1. Uninstall dutch language? 2. reinstall dutch ...
1 vote
0 answers
92 views

Install module Snowball Stemmer with composer and required library [duplicate]

I need a german Stemmer processor for my Search API in Drupal 8. Snowball Stemmer seems to be the right choice, but I can't get it to work. Snowball Stemmer requires a library. I think it is the ...
2 votes
2 answers
247 views

How to create a hook for a module in a theme?

I am trying to alter some data that is being passed from the Language Switcher module. Here is a code snippet from the module. if (isset($links->links)) { $build = array( '#theme' => '...
0 votes
1 answer
26 views

Create a link to the fist item of a specific view block

I have different view blocks on my front page and they contain number of contents such as images, articles, news etc. I've managed to get the block list and the block object for each item in that ...
0 votes
1 answer
269 views

Behat drupal 8 configuration

I have the following set up. I vagrant machine with d8 site setup. The files are common. I have replicated the DB in my laptop outside the host so I can run the behat tests faster. The DB is a dump of ...
3 votes
2 answers
3k views

tableselect form doesn't work

I can't get form-table of '#type' => 'tableselect' to work. I've lifted the example from 8.3.x core/lib/Drupal/Core/Render/Element/Tableselect.php Tableselect. The table works and there are no log ...
1 vote
1 answer
237 views

Incorrect branch when adding modules with composer

Edit: Gist of my complete composer.json I'm seeing some confusing behaviour with Drupal branch names when adding modules using composer - specifically I seem to be getting the 7.x version of the ...
0 votes
1 answer
264 views

How used function drupal_render_children in file twig?

I want use function drupal_render_children in file *.html.twig Drupal 8. What solution for do ?
3 votes
2 answers
1k views

How to get field mapping information in custom module?

I am trying to call field_info_field_map() in my DefaultForm.php . What is the right way? I am getting the following error: Error: Class 'Drupal\module_name\Form\Field' not found in Drupal\...
1 vote
1 answer
364 views

How can I force a view page not to be cached?

I created a few views which I use as JSON endpoints for a client application. However, they are not refreshed along with the content they serve. What I have tried with no success: Setting Caching to ...
5 votes
1 answer
5k views

Check the current page is a view

Is there a way to determine if you are on a view page, similar to \Drupal::request()->get('node') used to check if the current page is a node page? I need to adjust breadcrumbs for view ...
1 vote
1 answer
586 views

How to invalidate cache when a config entity is added/deleted?

In a MenuLinkContent entity I've a list_string field populated with a $key => $value array of a custom config entity. When I add or delete a config entity the values in my field are not updated ...
2 votes
2 answers
2k views

Accessing term's tid

I am trying to loop through a taxonomy term's tid, but somehow all the array elements are protected. It was very easy peasy in Drupal 7 with: $term_id_1 = $node->field_term['und'][0]['tid']; I ...
1 vote
1 answer
174 views

Functional test not displaying context aware block

I have a context aware block I've created. /** * Provide a context aware block. * * @Block( * id = "my_context_aware_block", * admin_label = @Translation("My context aware block"), * ...
7 votes
3 answers
13k views

Get the values of views fields in a Twig template

I have created a view that outputs 3 fields for each row. Just using views, i can get the output to look something like this: <li>[Field1 Value] [field2 value] [field3 value]</li> I have ...
2 votes
1 answer
2k views

Getting child term's Tid not the parent's

I created a form via Drupal 8 API, and I am creating a dropdown of a taxonomy terms which has a parent-child hierarchy. But when i select the taxonomy term, it displays term's parent's tid. This is ...
1 vote
1 answer
31 views

Print search field in template file

I need a search field to "pop down" under a search icon ({# Search icon #} in sample code) in my template file. But how do i print the search block directly into a template file? I want it to be in ...
0 votes
0 answers
432 views

how to get the block region value from the plugin block class build method?

how to access the set block layout region from a plugin block class build method ? class HalPublicationBlock extends BlockBase implements BlockPluginInterface { /** * {@inheritdoc} */ ...
6 votes
1 answer
186 views

How can I enforce maintenance_mode at all times in a specific environment?

In Drupal 7, we could override the $conf variables in settings.php to force a site (e.g. development) in maintenance mode. In Drupal 8, this has changed to $config, but the maintenance mode variable ...
2 votes
0 answers
751 views

multisite with shared user, shared session,separate role

I'm trying to build Drupal multisite with separate DB but shared user, session and separate roles. I did this in settings.php: Master/default/parent site: $databases['default']['default'] = array ( ...
3 votes
2 answers
5k views

How to force image URLs as HTTPS?

There are a few places where I am calling ImageStyle::load('style')->buildUrl($uri) to get a physical file path of an image. After enabling HTTPS and forcing all traffic to use HTTPS, I noticed ...
1 vote
1 answer
728 views

"The 'entity_type:block_content_type' plugin does not exist." Why? How?

My boss and I have inherited a Drupal 8 site from another developer, and every attempt to do database updates or cache rebuilds triggers a fatal exception: ‘The “entity_type:block_content_type" plugin ...
5 votes
1 answer
2k views

How to specify which form mode to use for a content type

I created a new_form_mode for a content type in D8 and removed some fields in that form mode from Manage form display tab of the content type by selecting that new_form_mode . But how can i select ...
3 votes
1 answer
1k views

Using attributes in templates Twig

I am a newbie. I have experience working with Twig but in Drupal it is used in another way. I have seen a lot of code like that <section{{ attributes.addClass(classes) }}> And of course I ...
0 votes
0 answers
433 views

How to present data in table grid?

I'm creating a Drupal 8 module which require to present data in table-grid manner something similar like below: The data will be retrieve in JSON format from REST API service (another server) - which ...
2 votes
0 answers
107 views

Creating input type=button [duplicate]

was tying to create a <input type="button" /> in drupal 8, below code snippet $button['button'] = array( '#type' => 'button', '#value' => $this->t('#Clear'), ); followed by ...
1 vote
1 answer
113 views

Set value after unpublishing content

I'm using drupal 8 and the scheduler module to automatically unpublish custom content after x days have passed. While unpublishing a boolean field from the custom content needs to be enabled/disabled....

1
249 250
251
252 253
316