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

How to redirect to frontpage from a controller

Right now I'm doing this ugly thing to get the url of the my set frontpage (skipping validations and making sure it exists since I'm not sure if I'll even use this approach) $url = $this->config('...
0
votes
1answer
80 views

How to get correct language code during installation?

I am programmatically creating some content during installation of my profile and I need to set the language for this content, otherwise it will be in English(which my site is not) and there will be ...
0
votes
1answer
369 views

How can I use $_SESSION in form handler drupal 8?

I create a module that has form . I want send data from other form to this form and show them . How can I save previous data in my form and show new data ? For example I send number 1 to my form and ...
0
votes
1answer
760 views

getting URL from Route: breaks in localhost subdirectory

I just had a Drupal 8 site break when moving it from a top-level domain on a server to a subdirectory on my desktop machine: apparently that subdirectory wants to be included in the URL as converted ...
0
votes
1answer
284 views

Adding content to Paragraph Date Field Drupal 8

I'm programmatically creating paragraphs using the following code, but I'm unable to get the date value to store correctly within the date field. It seems to store within the database, yet on the edit ...
0
votes
2answers
334 views

Hide a row from view display

I have a view which presents values of specific content type, nothing special, just a normal regular view with a table display. Later on I added to it a field from views field view module. Everythink ...
0
votes
1answer
713 views

Taxonomy term route name?

I am trying to make a custom taxonomy breadcrumbs based the code from this question: Drupal 8 How to do a custom taxonomy breadcrumb? This line adds a new breadcrumb for the home page: $breadcrumb-&...
0
votes
1answer
240 views

Creating a ticket system with core only. How to modify fields on full_content view without reloading?

I'm trying to create a ticketing system with Drupal 8 core. I know Drupal 8 has quick edit module, but that doesnt seem to be working in D8 core. Below is a very basic ticket I made as it just ...
0
votes
1answer
146 views

Update node revision programmatly

If i try to update node revision like this: $node = node_revision_load(59); $node->set('publish_on', null); $node->save(); or simple save: $node = node_revision_load(59); $node->save(); I ...
0
votes
2answers
549 views

Fetch fields of a block defined via content type programmatically

I've created a block type via the UI. This is a translatable block with 3 text-fields. I am using hook_block_view_alter($build, $block) to massage the data. However, I can not seem to find the fields ...
0
votes
1answer
861 views

drush updb fails with “the 'media_delete_action' plugin does not exist” after 8.4.6 > 8.5.1 update

We have recently updated a Drupal 8.4.6 installation via composer to Drupal 8.5.1. After the composer update I ran drush updb as usual. However, the command fails at one point with the following ...
0
votes
2answers
2k views

hook_entity_presave() doesn't work [closed]

I want to save some details before saving the node, and I tried with hook_node_presave(). function hook_node_presave(Drupal Core Entity EntityInterface $node) { if ($node->id() && $node-&...
0
votes
1answer
390 views

Why does the “Registration List” tab not appear for my events for users with adequate privileges?

I'm using the RNG events module in D8 - when a user with adequate privileges clicks the event tab, they can see and edit all fields, but the "Registration List" tab doesn't show, and they can't see ...
0
votes
1answer
533 views

How to print Json data from Facebook in a block?

I would like to print the amount of Facebook likes for a url into a block. The Facebook API returns JSON like so: https://api.facebook.com/method/fql.query?query=select%20like_count%20from%...
0
votes
1answer
495 views

Create user without password using rest api

From this documentation, currently what the User Registration resource does is to register a user that requires password in the Rest API. Our goal is to call/use this api endpoint http://localhost:...
0
votes
2answers
342 views

Help with database query

How can I convert this sql query into a Drupal 8 query? I need all nodes of type 'page' that has not been referenced by nodes of type 'article'. Article content type contains an entity reference ...
0
votes
2answers
156 views

Increase weight range for child pages in book outlines (Book module)

When a child page is added to a book via "Add child page" (node/add/{content-type}), the Weight drop-down field in the Book Outline tab has a range of -/+ 15. This is due to line 191 in web/core/...
0
votes
2answers
235 views

Creating a dynamic menu

I'd like to make a Drupal 8 menu dynamic so it can i.e. point to the latest node of the articles or news or hide another from the menu if it doesn't have an entry at all. How can I achieve this?
0
votes
0answers
726 views

drupal admin theme not working for roles other than administrator in drupal 8

I have a theme for the frontend and I use "seven" for the backend as I set it on admin/appearance. I created a new role: "power user", which is a limited access to the different content types. The "...
0
votes
1answer
630 views

Form fields created via Ajax are missing element attributes

I have a custom form with a date field and a series of textfields and number fields. The textfields and number fields are dynamically re-created via an ajax callback function that runs whenever the ...
0
votes
1answer
61 views

How to pass values to content creation page to set default values in form elements?

Introduction (not necessarily needed to be able to answer the question) I use Domain Access module to be able to manage different sites from one Drupal installation and a single shared database. I ...
0
votes
2answers
133 views

Route that renders a node has title of route rather than node title

I have a route that takes a wildcard $product and then loads a default node that is stored in config. This is working (i.e. the node is rendered on that path) but instead of the node title it is ...
0
votes
0answers
245 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} */ ...
0
votes
1answer
71 views

How do I show the members in a block, contextually filtered by the currently logged in user?

In my project every group member will only ever belong to a group; some group members have the Group Administrator role. I would like to create a view block to satisfy this story: As a user with the ...
0
votes
1answer
435 views

Cache context drupal don't work

I changed services.yml file (i use dynamic cache): renderer.config: required_cache_contexts: ['languages:language_interface', 'theme', 'user.permissions', 'cookies:Drupal.visitor.Country'] And sey ...
0
votes
2answers
148 views

Restrict creation of new taxonomy terms via node form through entity reference filed (autocomplete) for particular user role

I have Entity reference field (taxonomy terms ) in node form. I have checked the option (Create referenced entities if they don't already exist) so that users can create new taxonomy terms in field ...
0
votes
1answer
539 views

hook_ENTITY_TYPE_view() only fires once on cache rebuild?

When implementing hook_ENTITY_TYPE_view() for nodes, I notice the following behaviour: Cache rebuild Navigate to node/1 // Message 'Node viewed!' displays Navigate to node/2 // Message 'Node viewed!' ...
0
votes
1answer
67 views

Upgrading a simple drupal 7 module to drupal 8?

I am new to drupal and currently using version 8. I am trying to convert cricket feed widget module in drupal 7 to drupal 8 based on Community instructions.. But I am unable to understand the routing....
0
votes
0answers
248 views

User login REST POST returns HTML format [duplicate]

I want to login to drupal through JSON, I read this issue, but non of the proposed solutions helped me do that using Postman on drupal 8.2.5. specially when I send this specification : POST: http://...
0
votes
2answers
406 views

How can I alter the title of a node upon save?

I want to automatically set the title of nodes with content type ABC to the node ID. (I want to hide the title field from the form in the UI, and I don't care about titles for this content type.) ...
0
votes
2answers
356 views

How to remove status messages from admin theme?

I am working with Drupal 8. I have enabled "Seven" as admin theme. When I have added an image with high resolution I am getting 2 error messages at a time(screenshot). I want to hide "green" colored ...
0
votes
1answer
1k views

Programmatically load the page variant being used on path or node object

I'm attempting to be able to load a page variant given a specific path. My ultimate goal is to loop through all the links in a menu, find out what page_manager variant is being used and load the ...
0
votes
1answer
674 views

Convert hook_menu in drupal 8

I have a hook_menu as follows : /** * Implementation of hook_menu(). */ function conditional_fields_menu() { $items = array(); foreach (node_get_types() as $type) { $content_type = ...
0
votes
2answers
222 views

Allow users to use embedded HTML tags in custom blocks

I'm using CKEditor in Drupal 8 and the client wants to write HTML that contains embedded tags like so <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#...
0
votes
2answers
91 views

Packing taxonomy fields into one div not from SQL?

I created 2 taxonomy entity-reference fields. One is Categories and one is Tags and some similar other fields. In nodes, some of these taxonomy fields appear one above the other. I want to give some ...
0
votes
1answer
688 views

How to create and add a page to a book programmatically?

I have studied create nodes programmatically and create a book page but still i did not find how to create and add a page to the existing book. How to set parent child relationship if applicable. I am ...
0
votes
1answer
385 views

How do I convert the result fro views_get_view_result() to an array?

I am getting an object from views_get_view_result(). Array ( [0] => Drupal\views\ResultRow Object ( [_entity] => Drupal\node\Entity\Node Object ( [...
0
votes
1answer
662 views

Show contact form in a pop-up window with Bootstrap classes

Can you please tell us how to create a modal window with a contact form, with the bootstrap classes? I open the form with <a class="use-ajax" data-dialog-options="{ &quot;width&quot;:633 }...
0
votes
1answer
179 views

Core Updates after install with composer create-project drupal/drupal

So I installed Drupal with composer create-project drupal/drupal <...> It works fine, but now I'm trying to update core from 8.4.1 to 8.4.4 What's the right way to do that? composer update ...
0
votes
1answer
411 views

hook_entity_field_access - trying to check if there's a value

I am trying to check if a given FieldItemListInterface is empty or not (and if not, grab the entity) Using the example in https://www.drupal.org/project/examples - the team I'm on was able to get an ...
0
votes
3answers
1k views

How to redirect from URL with trailing slash to one without

We are using the Redirect module 8.x-1.2 with Drupal 8.5.6. When generating URLs, we are finding that a trailing slash is added to the end of the URL, and this is creating a 503 error code. How ...
0
votes
1answer
292 views

Injecting additional content from multiple sources into a block using twig

I have a module which presents a table of contents from a twig template of examples on to how to use the module. This listing is located at /flot-examples. I would like additional modules to be able ...
0
votes
1answer
146 views

Commerce 2 | Quantity Dropdown with Default Values -> Error

I need to allow the costumers to choose specific quantities for specific type of products but I would like to avoid adding 2 extra modules to my website ( Commerce Extended Quantity & Extended ...
0
votes
1answer
250 views

How can I avoid saved configuration settings to be exported?

I have a custom module and I added a form that allows the administrator to save some settings. Now, when I export the configuration (drush cex), I notice that these settings are being exported to a ...
0
votes
1answer
80 views

8 - Node::load is generating an object with circular reference which is crashing kint() and var_export()

I have a content type with a Taxonomy term which has fields. When I try and load a node (or possibly nodes) of this type I get unexpected results. While debugging with kint() and var_export() I get ...
0
votes
1answer
52 views

Can You Render Data from Forced Fields in Views While Using format “Show: Content”

Drupal 8.x Is it possible to render fields in a view when the display format setting is set to format "Show: Content" ? For my case, the contrib module I am using has some views integration that ...
0
votes
1answer
264 views

Is it possible to render a twig template for “later use”?

I have been asked to create a custom module that outputs a node's content in a way that it will be easy to print or export to pdf. I came accross this question and this is litteraly what I'd like to ...
0
votes
1answer
745 views

Changing '#view_mode' in content type's render array

I have a content type in Drupal 8 project that has image, name, info and body field as a default display, and image,name and information as a teaser display. I am able to display this content type ...
0
votes
1answer
63 views

Is referential integrity supported?

Does Drupal 8 support referential integrity? Can I tell Drupal what it should do if a parent row in a content type is deleted? For example: I could tell Drupal not to allow the deletion of a parent ...
0
votes
2answers
2k views

How to get node url from Entity Reference field?

We have an ECK Bundle that has an Entity Reference to Article and Basic Page content type. In the twig template we are using the following line below to get the node's nid value and then using that in ...