Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Hot answers tagged

3

Nodes are rendered only once per view mode and then are cached. So the easiest solution would be to configure different view modes. Which makes sense in this case, these are in fact two different displays of the same node. Another benefit, you don't need this hook, because view modes have theme suggestions out-of-the-box.


2

Normally you can simply update core and all extensions in a single pass: composer update Only if this doesn't work, try to update core in a separate step by following the procedures described in the drupal composer project: composer update drupal/core webflo/drupal-core-require-dev "symfony/*" --with-dependencies See https://github.com/drupal-composer/...


2

Solved it. I had to add that "webflo/drupal-core-require-dev" to update command to be updates as well, because without that core couldn't be updated: composer update drupal/core "webflo/drupal-core-require-dev" --with-dependencies Saw that in "known issues" section. :/ It's really strange - what's the purpose of --with-dependencies when I have to add ...


2

According to issue #2774255 and line 38 in the FormElementLabelTest.php you should be able to use #label_attributes for this. '#label_attributes' => ['class' => ['meow']], Update: Seems you can also try to do this by implementing template_preprocess_form_element. There's an example on line 493 in the form.inc. In your theme implement ...


1

Here is an example of sortable table with pagination. $header = [ 'label' => [ 'data' => $this->t('ID'), 'specifier' => 'nid', ], 'replies' => [ 'data' => $this->t('Title'), 'specifier' => 'title', ], 'created' => [ 'data' => $this->t('Created'), 'specifier' => 'created', // Set ...


1

Are you sure this is a coding error? Are you loading any large quantities of content in the form by any chance? Loading a lot of nodes in a select field, for instance, can generate memory overflows.


1

In Drupal 8, If the migration is one that is a config entity (shows up in /config rather than in migrations/) values can be overridden in settings.php or environment specific settings. // Set migration settings from environment variables. $config['migrate_plus.migration.node_article']['source']['urls'] = [getenv('CMS_ARTICLE_API_URL') . '/services/articles/...


1

The other question mentioned having passed that variable from a preprocess function to the template first. I guess that can be done using PHP's getenv then. Let me just try that out. Yep, that works. /** * Implements template_preprocess_page(). */ function MYTHEME_preprocess_page(&$variables) { $variables['my_environment'] = getenv('...


1

Ah yes, you are right. Image derivatives will be automatically generated once requested and not-yet existing. That's a quote from my own answer to a similar question. I guess you could try to hook into the upload somehow like Image Style Warmer does it, or simply try that module out yourself. Synopsis The Image Style Warmer module provides ...


1

Well, by now I just found that my question is technically wrong. Drupal is not supposed to do any redirect (HTTP 301/302) on access denied errors (HTTP 403). This is not how HTTP works (as mentioned by @Hudri in the comments). On an access denied error, Drupal replaces the actual page content with the one from the "Default 403 (access denied) page" site ...


1

The Webform module includes the 'Webform Demo: Event Registration System' module which shows how to pass field related tokens from a Webform 'event' node to a webform submission.


1

You need to get the values first you want to work with. For example the node object is inside $variables['elements']['#node']. In the sample below field_foobar is a text field. Depending on what your field type is you may need to get the value you want a little bit differently. And also maybe sanitize it first before you use it in a template suggestion (...


1

If you are using Content-Type: application/json please use : $post_data = json_decode( $this->request->getContent(),TRUE);


1

The person who does the CSS needs to design the dynamic property :checked, not the static attribute [checked]. The 2nd one is static in the HTML code and never updated after the intial page load, the first one is the currently selected input.


1

As already mentioned, <front> is a route, not a token, so you can't use the token API to work with it. You can resolve it using the Url class: $path = \Drupal\Core\Url::fromRoute('<front>')->toString(); // $path is equal to '/' But I'm not sure how useful that will be. Perhaps you want to get the front page that's set in config instead: $...


1

You can use : $build['test'] = [ '#children' => $test_code, ];


Only top voted, non community-wiki answers of a minimum length are eligible