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
0
votes
0answers
3 views

How to know a user can access node/{nid} and node/{nid}/latest in fastest way

I have a view displaying list of latest node revisions. The view has title field. The website gives users permissions to access node/{nid}(shows latest revision if published default revision doesn'...
0
votes
0answers
3 views

How to migrate D8 sites between installation profiles on Aegir?

How can be D8 sites migrated in Aegir between different installation profiles, and not only between platforms using the same installation profile? There is a solution in Aegir for D6->D7 and D7->D7 ...
1
vote
1answer
20 views

Why doesn't the batch process start?

I've created a class that extend the 'FormBase' class to create a form where I can upload a XLSX file to import into custom DB table. To process the import I would use the 'Drupal batch process' to ...
0
votes
1answer
7 views

How can we check whether block is enabled or disabled in .theme file?

I am displaying a block in twig and i am passing twig variable from hook_preprocess_page. But the issue when i disable the block from backend still its showing up in frontend. Im not able to get ...
0
votes
1answer
343 views

Manage Display Field Label not changing: inline does not work

I have the same problem as question 212176 and discovered it has to do with CSS. I have 2 (local) sites both with module ds enabled. I configured in both a field where I want the label and the value ...
8
votes
2answers
14k views

How do I add a variable for a Twig template in my preprocess function?

I'm using the following code to preprocess the variables for my template: function template_preprocess_imagegallery_format(&$vars) { template_preprocess_image_formatter($vars); $vars['image'][...
1
vote
1answer
100 views

Notice: Trying to get property 'nid' of non-object

In Drupal\rsvplist\Form\RSVPForm->buildForm(), I wrote this to get the current nid: $node = \Drupal::routeMatch()->getParameter('node'); $nid = $node->nid->value; I get this error: ...
0
votes
1answer
15 views

How do I programmatically delete a node by internal url alias?

How do I programmatically delete a node with a specific internal url alias? Background: We are trying to delete this node so that it can be replaced during an update hook.
0
votes
1answer
339 views

Sub-sub Theme Not Inheriting CSS

I am trying to extend the Thunder Admin theme by creating a sub-theme in it. This is my first time making a sub-theme in Drupal 8 (other than from bootstrap starter kits). I would have thought that a ...
0
votes
2answers
813 views

Form alteration is not working from within my form class

I am following https://www.drupal.org/docs/8/api/form-api/introduction-to-form-api for my hello world module. Below is my code namespace Drupal\hello_world\Form; use Drupal\Core\Form\FormBase; use ...
0
votes
1answer
636 views

How to get rid of an extra space in a twig date field template?

I have a twig date field template that has a mysterious extra blank space that I want to remove. In my twig template, field--comerce-product--field-ppromotion-enddate.html.twig, I have the following ...
0
votes
1answer
10 views

How to move block from a region inside of hook_preprocess_node?

I have added mycustomblock to the header region in our settings (/admin/structure/block). We are using the standard content block and displaying that in the Content region, which is displayed below ...
0
votes
2answers
430 views

Use of Twig template for webform email

I'm trying to help my father out by building a webform (D8 version) for the 4 theaters his Old Abbey Friends are putting up. I've made the webform, now i'm setting up an email handler so that ...
5
votes
4answers
12k views

How do I set the default value of a datetime form element?

I have a requirement of developing a custom contact form in drupal 8. I am able add all the fields but coming to date time field unable to set the default value to current date. This is my date field ...
4
votes
1answer
607 views

Action links available options / caching

I have some action links defined in module.links.actions.yml which uses a custom "create entity" route. For entity creation I set up some restrictions and at some point the access is denied. The ...
1
vote
1answer
23 views

Is the tags section valid in the info.yml file?

I see in the devel.info.yml file a section named tags tags: - developer But I can't find it on the documentation page. Is the tags section valid in the info.yml file or is it just an error?
0
votes
1answer
55 views

How to add field content as class in Twig?

I want to add the content of a field (i.e. "workshop") as a class in field-html.twig i tried {% set classes = [ 'field', 'field--name-' ~ field_name|clean_class, 'field--type-' ~ ...
2
votes
1answer
467 views

How to display parent Taxonomy ID in REST export

I want to configure REST export View in which I display taxonomy term name, id and parent ID. How to insert parent taxonomy term id, why it's not available in FIELDS? Here is current REST export ...
-2
votes
0answers
25 views

Custom pages for separate taxonomy terms [on hold]

I want to design different pages for different categories. For example, if I have 2 categories with machine names One Two I want to have pages like this page--taxonomy--one.html.twig page--...
0
votes
2answers
795 views

Drush not working after install

I just installed drush using "composer require drush/drush". It ran correctly and when it completes a navigate to vendor/drush/drush/ directory where the drush.php file is located Then I run the ...
4
votes
3answers
4k views

Alter the user registration form

I'm trying to change the label and field instructions for the name field on the User Account Creation form. I'm new to coding, and thought this would be an easy task. My custom module is enabled and ...
1
vote
1answer
39 views

How can I display the block title when rendering a block using Twig Tweak?

Block title when using twig-tweak plugin, not showing. I created a block-type view. And using the module's cheat sheets, I called: {{ drupal_view('views_name', 'block_1') }}
-1
votes
1answer
1k views

How to change views field value using a hook

I want to change drupal 8 views field value before displaying. I am using below hook_views_pre_render function MYMODULE_views_pre_render(ViewExecutable $view) { if ($view->id() == "demo1" &&...
1
vote
1answer
23 views

How to change the date format in the date field as a select list?

On user registration page, I have added a date field in select list. In the manage form display tab, I can set the order of the dropdown fields like day/month/year or month/day/year But I am unable ...
1
vote
1answer
3k views

How can I render an entity in a string?

Is it possible? To use the viewBuilder of an entity to generate the complete html and save that output into a string instead of sending it to a browser. It would open the possibility to have email ...
0
votes
0answers
6 views

Strong commerce order line items grouping

I need add to cart some Order Line Items grouped to don't allow the user to remove or change the amount of one of them without changing the other too. I can't do this with a unique Order Line Item ...
0
votes
1answer
12 views

Load Media File in Webform Mail Handler

I want to use a single webform to send download links with specific media files to visitors that fill out that form. For example on an URL like this: https://example.com/downloads?media=1234 The ...
0
votes
2answers
2k views

Delete multiple entites without loading them - running out of memory

I'm deleting multiple nodes like this: $nids = [21,12,45,67]; // Just an example, this data comes from elsewhere $nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids); \...
3
votes
1answer
29 views

How can I disable meta tags provided by the Metatag module for a custom route?

I have created a custom module for displaying the players information. Module will create dynamic pages and each page will display players stats. With the help of the following links, I was able to ...
0
votes
1answer
22 views

Output og:image:url if the og:image exists

I'm working on a website with Drupal 8 and the metatags module. I need to not output the metatag og:image:url if the og:image exists. If it possible to do using the module? If not I would have to ...
0
votes
0answers
8 views

How do i dynamically import changing feed links within a feed

I am uncertain how to approach this. I have a feed with housing cases that is changing constantly. The feed consists of a case number and a feed link to that particular house. Each house has so much ...
0
votes
2answers
35 views

How do I print individuals fields in block.html.twig when is a node in a block?

How do I print individuals fields in block.html.twig when is a node in a block? The template is working fine. I can hard code some random text and it is displayed. I just can't display the field ...
0
votes
2answers
20 views

Views footer include twig

Is there any way to include an if condition in views footer. I have to check the total rows {% if [view:total-rows] > 6 %} <div class="btn">View AllEvents</div> {% endif %} But this ...
0
votes
0answers
25 views

Dynamic meta tags and description in custom pages [duplicate]

I have a custom drupal module which will generates pages for players in my site. The players stat data is meant to be updated most of the time, so for ease of use, I have created a custom module for ...
0
votes
2answers
592 views

Generate meta in controller

I'm creating a custom module. This module displays public custom content without node and views . For this content custom page , I would like to add dynamic meta keyword and meta description . I ...
0
votes
1answer
16 views

Link to node in View with TWIG

I have a set of nodes, some of which are just a title, while others have body and other content. I'm trying to create a view, which lists the node titles. If the body of the node contains content, ...
0
votes
2answers
472 views

Serialize selected fields

I have a requirement in a project having 350 fields, but when I use views, I am facing a lot performance issues. So in place of reading all the data from individual tables, can I use serialization as ...
1
vote
1answer
40 views

Programmatically check the checkbox of an exposed filter

I need to check a checkbox on an exposed filter for a view based on the url. I can't seem to figure out how to do that. If x is detected in the url, I want to set one of the fields of an exposed ...
1
vote
2answers
344 views

The missing modules don't get installed after updating with Composer

To update a site locally, I cloned the code base with git to my local computer and imported the database, then ran "composer update --with-dependencies", there were no errors, then I went to /web ...
0
votes
2answers
448 views

Add class to {{ link }} twig attribute

I'm trying to apply a button class to the {{ link }} attribute in code below. <span{{attributes}}><a class="usa-button"{{ link }}</span> It displays correctly however the markup is ...
0
votes
1answer
338 views

How do I count the number of Facebook likes in articles?

I am working on a Drupal 8 site. I added fblikebutton to my articles to enable users to like content. Is it possible to get the number of likes for each article as field? I am using the Views ...
2
votes
1answer
6k views

Alter views results in a hook

When I use contextual filters in a view, I can select an option to display a summary when the argument is not present. If I do it, it shows a list of node IDs instead of titles. For example, I get the ...
1
vote
2answers
450 views

Error installing CiviCRM

Following the amazing work @david-snopek posted: Blog post - CiviCRM & D8, David's StackExchange Post. I spent the better part of last evening trying to get CiviCRM up and running on a Drupal 8....
4
votes
1answer
649 views

How do I remove JOIN in hook_views_query_alter()?

I have a view with two filters (A + B). Filter B should only be included in the query, if a specific value in filter A is set (like a "conditional filter"). So I tried to remove the where condition ...
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 \...
1
vote
1answer
52 views

How to store temporary metadata for the remainder of a request?

I am looking for a way to store some additional metadata for the remainder of a request, that should be removed after the request has finished. Sessions or SharedTempStore store persistent data across ...
1
vote
2answers
1k views

Views breadcrumb

I need to have breadcrumb builder that will make all "News" nodes appear as breadcrumb children of a View we've created at /news I did follow this post : Add a breadcrumb to a view page? But it ...
1
vote
1answer
21 views

How to get a taxonomy custom image field URL value

I've created an image 'field_term_preview' field on the taxonomy vocabulary and trying to get this URL in my custom module: $terms =\Drupal::entityTypeManager()->getStorage('taxonomy_term')->...
1
vote
1answer
39 views

Entity reference view depending on other field [on hold]

I have a custom content type that contains an entity reference field (field_referencefield) and one more field as select box (field_triggerfield). The values of field_referencefield should depend on ...
1
vote
1answer
68 views

How to post node tags using REST API?

There is no problem with a node creation with filled in title/body/custom text field fields using REST API. We just need to send a post request with the following body: { "_links": { "type": { ...