When we build a form with text_format field in Drupal 8, images inserted in ckeditor is temporary and will be deleted 6 hours after cron by default.
Drupal 8
1. 管理匿名用户Form页面缓存
use Drupal\Core\Cache\Cache;
// 在匿名用户可以访问的表单里加入下面逻辑,包括列表页面和具体的查看页面
$form['#cache']['tags'] = ['your_custom_tag_name'];
// 在写入逻辑里让缓存失效
Cache::invalidateTags(['your_custom_tag_name']);
2. 禁用匿名用户Form页面缓存
在<module>.routing.yml文件路由定义里增加no_cache: 'TRUE'可禁用缓存
本教程不讲安装,不讲CMS部分,直接讲述如何编写Drupal 9模块。部分内容还是基于Drupal 8的,但基本也适用于Drupal 9和Drupal 10。
- Coder: 检查代码是否符合规范
- Examples: 扩展编写例子
- 先安装一个RESTUI模块
- 启用配置好之后可以访问GET接口,例如:http://cto.eguidedog.net/node/241?_format=json
-
POST接口,例如:curl -H "Content-Type: application/json" -X POST -d '{"type":[{"target_id":"braille_printing_application"}],"title":[{"value":"test2"}],"field_address":[{"value":"addr2"}],"field_name":[{"value":"name2"}],"field_phone":[{"value":"phone2"}],"field_zipcode":[{"value":"zipcode2"}]}' http://cto.eguidedog.net/entity/node
Drupal 9教程:https://www.specbee.com/blogs/programmatically-creating-block-in-drupal-9
官方教程:https://www.drupal.org/node/2101565
个人遇到两个坑:
1. Drupal 8不能再像Drupal 7那样通过arg获取参数了。下面是获取参数的一个例子:
$node = \Drupal::routeMatch()->getParameter('node');
if ($node)
$nid = $node->id();
First, it's really a bad idea to use Drupal 8 beta version on production site like me. Because Drupal 8 beta release do not provide a way to upgrade between beta versions. The database and API are not frozen at all.
If you are unlucky like me, you can try following steps:
热门内容
最新内容
- 1 week 5 days ago
- 2 weeks ago
- 3 weeks 2 days ago
- 3 weeks 3 days ago
- 3 weeks 4 days ago
- 1 month ago
- 1 month ago
- 1 month ago
- 1 month 1 week ago
- 1 month 1 week ago
最新评论