Questions tagged as ['8']

Version tags should be used for questions that apply to a version only, not to merely say what version a site is using.
Score: -1
View with multiple blocks, how to specify which is shown?
ph flag

I have a view that is placed as a block below my main content. Within that view I have block "displays". each having a different contextual filter for their id from url.

The problem is when the view is displayed, it only shows one of the Displays, how do i specify which is shown ?

enter image description here

Score: 3
chantdev avatar
Can BigPipe exclude certain blocks?
et flag

I've got BigPipe enabled in Drupal 8, and it helps to make pages initially load faster.

However, the header block is always one of the blocks that loads in on a delay, which visually looks bad since the content shifts down afterwards.

Is there any type of preprocess on a block to exclude it from BigPipe not be loaded on a delay, and force it to be in the initial page load?

Many thanks.

Score: 0
Composer require installation profile constraint match error
us flag

I am trying to download this install profile https://github.com/UH-StudentServices/student_guide

I added it to composer.json like this

"repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        {
            "type": "vcs",
            "url": "git@github.com:UH-StudentServices/student_guide.git"
        }
    ],

Then I did composer ...

Score: 0
Corentin Le Fur avatar
setError or setRebuilld methods breaks validation form
vn flag
<?php

namespace Drupal\my_custom_module\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Class DefaultForm.
 */
class DefaultForm extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'default_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $fo ...
Score: 0
Ivan Ginovski avatar
Display Node Local Tasks Menu on View
jp flag

I have a view that shows registrations for an Event (Content Type). This tab is shown in the /node/{node}/edit:

menuregistrations

This registrations tab refers to the view, which I have inserted in the routing.yml:

events.registrations:
  path: '/node/{node}/registrations'
  defaults:
    _entity_view: 'registrations.page_1'
  requirements:
    _custom_access: '\Drupal\events\Access\EventsRegistrationsAccess::checkAcc ...
Score: 2
jhnc avatar
correct way to access node-revision change property in twig
cn flag

I have a Drupal 8.9.17 website. My theme (based on Garland) includes in templates/page.html.twig:

{% if node %}
[...]
Last updated {{ node.changed.value|format_date('custom', 'D M d Y') }}
[...]
{% endif %}

This displays the property when viewing nodes at: /node/<nid>

However, when attempting to view revisions at /node/<nid>/revisions/<vid>/view, format_date() fails with "null times ...

Score: 0
Let anonymous user download pdf off his own webform submission
ng flag

I have configured entity_print with webform for D8 and can download a submission as pdf from the submission view.
Now I tried to let anonymous users fill out a form and added a link to the pdf on the confirmation page. I checked the show own submissions for guests on the permission page of that webform.
But when I try to access the pdf with the submited data I get a permission denied message.
http://m ...

Score: 0
scaffolding avatar
Updated: Webform tokens present user-submitted data for form fields
es flag

I'm attempting to build a webform (Webform 8.x, Drupal 8) that requires the ability for a user to submit the form multiple times.

To simplify the process for users, I'd like to set up some form fields to:

  • be empty by on their first visit to the form
  • for subsequent renders of the form, some form fields should be prepopulated with submissions from the previous submission

Is there a way to achieve this  ...

Score: 0
latikas avatar
Migrate nodes with Paragraph from json
ru flag

My goal is to import json file into Drupal 8 using Migrate modules (migrate_plus, migrate_tools). I use Paragraph module with fields like Name (entity reference) and composition (Number-float). And in node, I have title and other fields with Paragraph reference field. I do import, sometimes the node will be generated with blank paragraph name, If I reset migrate and try to import again, db logs gives fo ...

Score: 1
Chris Roditis avatar
Ajax form inside custom system.404 route controller doesn't work
in flag

I need to display custom logic in 404 pages so I have overridden the route controller of the system.404 route like this:

class RouteSubscriber extends RouteSubscriberBase {

  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('system.404')) {
      $route->setDefault('_controller', '\Drupal\mymodule\Controller\myController::on404');
    }
  }
}
Score: 1
berliner avatar
How to create automatic url alias for taxonomy/term/%tid/feed
bd flag

How can I set automatic URL aliases for taxonomy feeds?

Say I have a term with tid=1, named holidays, with a system URL of /taxonomy/term/1 that is accessible by the URL alias /holidays. Then I want the rss feed for that term to be accessible on the URL alias /holidays/feed or /holidays/rss.xml. That sounded rather easy when I first thought about it, but it seems that pathauto is not supporting that (o ...

Score: 1
How to determine which password hash is used?
us flag

We have migrated website from a vanilla coded PHP to Drupal, and I have also migrated all the users.

The old website has been using the password_hash() function to encrypt the password.

The website has been running for a month now. I'm looking at the user table, and I want to know determine which users has been encrypted using password_hash() or the default Drupal one.

I have this code

$query = \Drupa ...
Score: 0
scaffolding avatar
Adding Javascript within a hook_entity_type_presave() hook
es flag

I'm trying to add Javascript into a hook_entity_type_presave() hook, but it's not firing.

Is it possible to add within this hook?

I've attempted to with no success -- my code is below -- and this example on Drupal.org: https://www.drupal.org/docs/drupal-apis/javascript-api/add-javascript-to-your-theme-or-module ...describes the process of adding javascript within the context of two other custom modu ...

Score: 0
Filtering on child properties in GraphQL
hu flag

I am using GraphQL to get a list of upcoming events. I am having trouble finding the correct way to filter on the date value which is a child of my date field.

The query, which works:

query getUpcomingEvents {
  nodeQuery(
    filter: {
      conditions: [
        {operator: EQUAL, field: "type", value: ["ain_event"]},
        {operator: EQUAL, field: "status", value: ["1"]} 
      ]
    }
  )
  {
 ...
Score: 0
fin avatar
How is the cache invalidated?
th flag
fin

Using the following code, are all the cache bins consider when invalidating a content piece?

$variable['#cache'] => [
  'keys' => ['key string here'],
  'tags' => ['tags string here'],
  'max-age' => 'max age'
];

For example, If max-age is set to 15 minutes, is the content invalidated every 15 minutes? Does any change to the cache tags invalidate the content?

Score: 0
ACanadianCoder avatar
SOLR displays "submitted by username" only for the Article content type. How do I stop this?
br flag

No matter what I do, I can't seem to remove the Submitted by [username] from popping up in my search results for the Article content type. I'm using the Apache SOLR module. If you visit the article page itself, I never actually display this information, so showing up on the search results page is confusing me.

When I go to manage fields for my search results, I've got the following for content (I  ...

Score: 0
How do I change a display plugin class
vn flag

I'm attempting to modify the definition of a view display plugin to use my own custom class. I used hook_views_plugins_display_alter(), but it doesn't seem it's invoked at all. I've searched in core code where the hook is invoked, but I didn't find it.

Does anyone know an example of using this hook, or another way to override the class for a view display plugin?

Score: 0
Jean da Silva avatar
Cron is running but not saving entity
cn flag

I am trying to create a simple hook_cron to connect with an external API, return some data and update some fields in some entities. I'm creating like this to understand better how cron works, so I will upgrade it later to a queue.

The problem is that the cron is running, but even without errors the entity is not saving or updating. If I copy the code and try to execute it with a route (not using  ...

Score: 0
khadidja avatar
Views Infinite Scroll class wrapper goes away when filtering using facets, changing my CSS styling
cn flag

I have a page with custom css that uses display:grid for content output from my view. The limit I have for what my view outputs is 30.

Since the views infinite scroll contains a wrapper around my content, my css grid styling is all there, however when I use my facet to filter anything with an output less than 30, the wrapper vanishes as does all the styling. The wrapper then becomes a different c ...

Score: 1
scaffolding avatar
Add a hero image and text when a node goes from unpublished to published
es flag

I'm trying to add a hero image and text when a node goes from unpublished to published. The things include:

  1. Add an image from my media library to a media field on the node
  2. Add a page title to the node, drawing upon a field already saved on the node

I'm attempting to build a hook on hook_node_update() but it's not working. I'm not sure why.

The code I am using, part of the running_event_adding_header. ...

Score: 2
metalac avatar
Need to add multiple roles to routing.yml file
us flag

I want to assign multiple roles in my routing.yml file :

requirements: _role: "['role1', 'role2', 'role3']"

This is what I currently have, and it doesn't work.

Can someone tell me how to add this?

Thanks in advance!

Score: 2
Kevin avatar
Debugging "UNCACHEABLE" header
in flag

We have a site where the homepage is not being cached and contains the headers:

x-cache: MISS, MISS
x-cache-hits: 0, 0
x-content-type-options: nosniff
x-drupal-dynamic-cache: UNCACHEABLE

I narrowed this down to the content regions contents, and disabled the "Main page content" for the front page. This then gave me a cache HIT, and no longer responded as UNCACHEABLE. From there, I narrowed it down to a  ...

Score: 0
How to show error on screen after failling a webservice call on Webform submitForm?
in flag

I made a custom handler for one of my webform to call a service when the form is submitted. Here is my code. It is working when the service return a response with status code = 200 but I cannot find a way to notify the view when an error is raised by the webservice. I would like to show a modal with an error message but cannot find how to do this.

class CRMWebformHandler extends WebformHandlerBase  ...
Score: 0
liquidcms avatar
How to programmatically grant access to private files?
us flag

I was working under the idea that i could use hook_file_download to grant access to private files; but it seems that this hook can only be used to restrict access to files, not to grant access.

I have seen suggestions of other hooks like file_access and file_access_alter; but none of these exist any more.

Score: 0
Display Block to retrieve information from Order Item's Product Variant and display rating & review inside product page
cn flag

I am working on an e-commerce website development. I have the conventional Products -> Product Variants which goes through Order and payment gateway workflow. However, there is something different in this conventional scenario.

I have setup Product -> Product Variation to categorise the different type of fabrics which fall under a same style.

We have different kinds of fabric which we source f ...

Score: 0
Free Radical avatar
What controls the placement of links relative to the body?
kz flag

I am struggling with getting the "Read more" and "Add new comment" links placed below the body on a custom node content type called "Wikitext" that has been created using the GUI on a Drupal 8.9.17 website.

The site is running the default theme (Bartik) and I have not edited any templates. The built-in content type "Article" shows these links below the body. "Wikitext" is supposed to be identical ...

Score: 2
Can you rename replacement pattern tokens in views?
ru flag

If you insert one or more custom text field (e.g. to include some Twig logic), latter fields will see such blocks as {{ nothing }}, {{ nothing_1 }} etc. in the replacement patterns.

Can these be renamed? The label and the admin description make no difference.

Score: -1
fin avatar
Why does my shopping cart item not have a label?
th flag
fin

I'm working on D8 site with Drupal Commerce. I have to create a dynamic product variation and add it to cart for the user checkout.

The problem I have, is when you land on the cart page, the line item doesn't have a label (title) it replaced with the price of the item. Please refer to the attached image.

Here's my code:

   //create variation
            $variation = ProductVariation::create([
            ...
Score: 0
Ruzanna Hovasapyan avatar
How to programmatically add a paragraph item to a user account?
cn flag

I already added the Check in/out History field to the user account, which has the check-in date and check-out date fields.

How can I programmatically add new items to Check in/out History?

I need to create some history for users.

Check-in date Check-out date
04/05/21 05/07/21
03/05/20 04/14/20
Score: -1
Why do I get "An invalid selection has been identified." from the form my code creates?
ng flag

I am using the following code for a form.

public function buildForm(array $form, FormStateInterface $form_state) {
  $region_options = static::getFirstDropdownOptions();
  $form['vvv_region'] = [
    '#type' => 'select',
    '#title' => $this->t('region select field'),
    '#options' => $region_options,
    '#empty_option' => t('- Select region -'),
    '#ajax' => [
      'callback' ...