Drupal Planet

Drupal StackExchange

Can't seem to find a way to have & in a term description show up as &

3 days 21 hours ago

In a site on D9. I have a vocabulary that has titles as the term descriptions.

One of the term descriptions is This & That No matter what I try, the & is converted to & in CKeditor4.

This happens as soon as it's typed. I.e., clicking Source shows the text as

<p>This &amp; That</p>

and the eventual rendering is the same. I've tried all text formats for the CKEditor text, and have, in the Basic filter, turned off any plugins for fixing HTML, etc., No effect.

As to the suggestion of using the raw value. The field in the view is set to rewrite results as such:

{{ description__value__value }}

with description__value__value being defined in the list as the raw value.

The preview (and actual page using the block) show the result as:

  • This &amp; That
JAyenGreen

how to rename file before/after upload

3 days 21 hours ago

I want to rename an up-loaded file. I have the following code. I have defined a submit handler to do so.

function example_form_submit(&$form, FormStateInterface $form_state) { if ($form_state->hasFileElement()) { $video_file_file_array = $form_state->getValue('field_video_file'); if (is_array($video_file_file_array)) { if (isset($video_file_file_array[0])) { $video_file_file_id = $video_file_file_array[0]['fids'][0]; if($video_file_file_id){ $file = \Drupal\file\Entity\File::load($video_file_file_id); $file->set('filename', 'something'); $file->save(); } } } } }

This is not working. Is there any other way.

Dushyant Joshi

Mismatched entity and/or field definitions

3 days 21 hours ago

I have no idea how to fix this, I don't even understand what the problem is.

Mismatched entity and/or field definitions The following changes were detected in the entity type and field definitions. Taxonomy term The Term ID field needs to be installed. The UUID field needs to be installed. The Language field needs to be installed. The Vocabulary field needs to be installed. The Name field needs to be installed. The Description field needs to be installed. The Weight field needs to be installed. The Term Parents field needs to be installed. The Changed field needs to be installed. The Default translation field needs to be installed. The taxonomy_term.field_icon field needs to be installed. The taxonomy_term.field_link field needs to be installed. The taxonomy_term.field_meta_tags field needs to be installed.

I tried drush entity-updates but it finishes on error:

Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /var/www/vhosts/mysite/httpdocs/core/lib/Drupal/Component/Serialization/Yaml.php on line 54 Drush command terminated abnormally due to an unrecoverable error. [error] Error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /var/www/vhosts/mysite/httpdocs/core/lib/Drupal/Component/Serialization/Yaml.php, line 54

EDITED (after fixing drush install) I get the following for drush entity-updates

-sh-4.1$ drush entity-updates The following updates are pending: taxonomy_term entity type : The UUID field needs to be installed. The Language field needs to be installed. The Vocabulary field needs to be installed. The Name field needs to be installed. The Description field needs to be installed. The Weight field needs to be installed. The Term Parents field needs to be installed. The Changed field needs to be installed. The Default translation field needs to be installed. The taxonomy_term.field_icon field needs to be installed. The taxonomy_term.field_link field needs to be installed. The taxonomy_term.field_meta_tags field needs to be installed. Do you wish to run all pending updates? (y/n): y Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. Cannot add unique key [error] taxonomy_term_field__uuid__value to table taxonomy_term_data: unique key already exists. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1470 of /var/www/vhosts/mysite/httpdocs/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php). Failed: Drupal\Core\Entity\EntityStorageException: !message in Drupal\Core\Entity\Sql\SqlContentEntityStorage-&gt;wrapSchemaException() (line [error] 1470 of /var/www/vhosts/mysite/httpdocs/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php). Cache rebuild complete. [ok] Finished performing updates.

The bizarre thing is that all these things (field_icon, link, meta_tags..) are installed.

The site has many modules (both custom and from the drupal community) and it works alright. Should I export it all and do a clean install and then import it?

UPDATE

I did not manage to fix this and it was giving very weird problems out of the blue, although the already created content types and nodes worked fine. After 24h+ of non stop working I reset the stype up from a clean install and copied content manually (tried doing the Configuration > Configuration synchronization with single items, but it didn't work very well).

I can report now that the problem is gone. I have no idea what could have caused it or even when.

Chayemor

How to get S3 file path from URI?

3 days 23 hours ago

So inside my hook function I have URI of some file and I need to find it's S3 path (using s3fs module). How can I do that, to avoid manual string manipulation? Is there some helper function?

I found convertUriToKeyedPath() of S3fsStream class but it's protected and also it says "Converts a Drupal URI path into what is expected to be stored in S3" and that "expect is potentially dangerous.

MilanG

Loading mixed content

4 days 1 hour ago

I have a site loading over https. However, two items are being picked up in Chrome as targeting http, and I can't figure out where to look to change them. They are:

  1. GSS search form: we are using Google Site Search module, and it's posting to http.

  2. Drupal Views are posting to http, rather than https. Not sure how to override this.

Any help would be greatly appreciated. Thanks!

cbcorbett

Can you set default configuration settings for a contrib on install?

4 days 2 hours ago

I am looking to set default configuration settings for a contributed module, Nodeaccess, on install. I know that you can do that on site spin-up but this module will not be enabled by default. I tried creating a nodeaccess.settings.yml and placing it in the config/install folder but when I go to enabled the Nodeaccess module, an error notification appears: Unable to install Nodeaccess, nodeaccess.settings already exists in active configuration.

Is there a way to set default configuration settings for Nodeaccess on install? Thanks for your time.

-Chad

Chad