drupal-8

PHP PDOException: SQLSTATE[HY000] [2019] Can't initialize character set utf8mb4

偶尔善良 提交于 2019-12-07 06:05:33
问题 I have drupal 8 installed on Centos 6. Here is my php and mysql -version output Server version: 5.7.9 MySQL Community Server (GPL) PHP 5.6.14 (cli) (built: Oct 16 2015 08:41:09) But i still getting a connection error PDOException: SQLSTATE[HY000] [2019] Can't initialize character set utf8mb4 (path: /usr/share/mysql/charsets/) in /var/www/m2m/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php on line 83 I also have this configuration on my OS X Mysql Server version: 5.6.27

Drupal 8: delete all nodes of the same type

微笑、不失礼 提交于 2019-12-06 18:29:53
问题 I have a need to remove all nodes of the same type in Drupal 8 (there are over 7k of nodes). It wouldn't be a problem for Drupal 7 (DB query + node_delete or node_delete_multiple would have solved my issue). However, D8 is slightly different :) Please, advice, how can I do it. Thanks in advance! 回答1: One should use entity queries instead of acting directly on the database: $result = \Drupal::entityQuery('node') ->condition('type', 'my_content_type_name') ->execute(); entity_delete_multiple(

How to restore default homepage?

雨燕双飞 提交于 2019-12-06 15:39:19
I'm new to Drupal, and cannot understand how to do this: I must have accidentally deleted the default home page in my test site, and cannot find a way to restore it. I see I can create a new basic page and set it as my new home, however this is missing something - for example it does not show latest articles with the "main page content" system block, even if I set this new page as the homepage in site settings. Should I do something more to let Drupal know this is actually an homepage? And isn't there a way to restore the original default home page? If I delete the custom page and let the

Drupal 8 fetch content and serve without header/footer

有些话、适合烂在心里 提交于 2019-12-06 15:09:18
I'm working on a Drupal 8 site where I have a custom module/block that fetches content from another server and injects it to a div. When a user clicks on a link (like read more) from the injected content, I need to serve the content (full html page) (that gets fetched from the server) without my template's header and footer. My question is how can I serve a page without my template's header and footer? Thanks you. This is an old question but it's coming up in searches and I wanted to post a solution. If you want to serve just some custom HTML include the Symfony HTML response class and call

How to set file usage on drupal 8?

浪尽此生 提交于 2019-12-04 21:17:20
How to set file usage on drupal 8 ? and how to use below methods in drupal 8? file_usage_add. file_usage_delete. file_usage_list here i have added equivalent syntax for Drupal 7 and Drupal 8 file_usage_add -> \Drupal::service('file.usage')->add file_usage_delete -> \Drupal::service('file.usage')->delete file_usage_list -> \Drupal::service('file.usage')->listUsage //Add / Delete file usage $entity_type = 'node'; $entity_id = 1;//Node ID $fid = 1; // The file ID $file = \Drupal\file\Entity\File::load($fid); $file_usage = \Drupal::service('file.usage'); $file_usage->add($file, 'mymodule', $entity

How to create a form using block module in drupal 8?

佐手、 提交于 2019-12-03 10:14:25
问题 I want build a form using a block module in Drupal 8 . I am aware of building the forms in Drupal 7 but the same seems to be different in Drupal 8. Request anyone who has worked on drupal8 custom forms as block to help me. 回答1: Your question is very vague, as I don't know how much you already know about modules, forms and blocks in Drupal 8. So here is a small guide what to do, further information on how to do stuff in detail would be overkill for this answer. 1. Create a new module and

drupal 8 get taxonomy term value in node

妖精的绣舞 提交于 2019-12-03 07:28:42
Drupal\node\Entity\Node Object ( [in_preview] => [values:protected] => Array ( [vid] => Array ( [x-default] => 1 ) [langcode] => Array ( [x-default] => en ) [field_destination] => Array ( [x-default] => Array ( [0] => Array ( [target_id] => 2 ) ) ) Not able to get field_destination value directly. It's a taxonomy term attached with the content type. Any help appriciated. Christian To build on VJamie's answer. You will need to either set a use statement at the top of your script; use Drupal\taxonomy\Entity\Term; Or, prefix the class instance with the namespace; $term = \Drupal\taxonomy\Entity

How to create a form using block module in drupal 8?

我只是一个虾纸丫 提交于 2019-12-03 03:59:42
I want build a form using a block module in Drupal 8 . I am aware of building the forms in Drupal 7 but the same seems to be different in Drupal 8. Request anyone who has worked on drupal8 custom forms as block to help me. Frank Drebin Your question is very vague, as I don't know how much you already know about modules, forms and blocks in Drupal 8. So here is a small guide what to do, further information on how to do stuff in detail would be overkill for this answer. 1. Create a new module and enable it Look here: Naming and placing your Drupal 8 module . Basically you create the module

How to use docker with drupal and drush?

ぐ巨炮叔叔 提交于 2019-12-03 03:17:29
问题 I'd like to use drush. It needs to run in the drupal container. There's also a drush docker repo. But I have no clue how to make it available whithin the drupal container. It's my first docker and drupal project, so maybe I'm getting things completely wrong. How can I use drush with this drupal docker image? https://hub.docker.com/_/drupal/ Is it possible to manage it with docker-compose? Maybe extending the drupal container? This is my docker-compose.yml : mysql: image: mysql:5.5 ports: -

How to update my View in Drupal 8 without scrolling back to the top?

梦想与她 提交于 2019-12-02 17:02:28
问题 I'm trying to refresh my View in Drupal 8 without reloading the page with this code : (function ($, Drupal) { 'use strict'; setInterval(function() { $('.view-message-activity-stream-timeline-public').trigger('RefreshView'); }, 10000); })(jQuery, Drupal); It works. My problem : Each time the view is refreshed, that page scolls back to the top of the view. There is another problem with the refresh of the page. When I click the "Afficher plus" link at the bottom of the home page, page 2 appears