我正在使用Wordpress模块从Wordpress迁移到Drupal 8,我试图将别名设置为链接值(<link>https://myurl.com/wordpress-path</link>)。我在消息来源中添加了以下内容:
-
name: link
label: 'The link value'
selector: 'link'并进行以下处理:
path/pathauto:
plugin: default_value
default_value: 0
alias:
-
plugin: get
source: link
-
plugin: str_replace
source: link
search: 'https://myurl.com/'
replace: '/'我也尝试过path/alias和path,而不是alias,但是没有运气。我验证了str_replace插件确实返回了正确的值,但不知何故它没有保存在节点中。
这是我的完整migrate_plus.migration.my_wordpress_wordpress_content_post.yml:
uuid: 5b3b3b84-8d41-4a80-b1ca-c9046c269297
langcode: en
status: true
dependencies: { }
id: wp_wordpress_wordpress_content_page
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags:
- WordPress
migration_group: wp_wordpress
label: 'Import content from WordPress XML'
source:
plugin: url
data_fetcher_plugin: http
data_parser_plugin: xml
item_selector: '/rss/channel/item[wp:post_type="page"]'
fields:
-
name: title
label: 'Content title'
selector: title
-
name: post_id
label: 'Unique content ID'
selector: 'wp:post_id'
-
name: content
label: 'Body of the content'
selector: 'content:encoded'
-
name: excerpt
label: 'Excerpt of the content'
selector: 'excerpt:encoded'
-
name: pubDate
label: 'Publish date of the content'
selector: pubDate
-
name: post_date
label: 'Post date of the content'
selector: 'wp:post_date'
-
name: status
label: 'Published status of the content'
selector: 'wp:status'
-
name: creator
label: 'Username of the content creator'
selector: 'dc:creator'
-
name: post_tag
label: 'Tags assigned to the content item'
selector: 'category[@domain="post_tag"]/@nicename'
-
name: category
label: 'Categories assigned to the content item'
selector: 'category[@domain="category"]/@nicename'
-
name: link
label: 'The link value'
selector: 'link'
ids:
post_id:
type: integer
process:
title:
-
plugin: get
source: title
body/value:
-
plugin: get
source: content
body/summary:
-
plugin: get
source: excerpt
created:
-
plugin: callback
source: post_date
callable: strtotime
changed:
-
plugin: get
source: '@created'
status:
-
plugin: static_map
source: status
default_value: 0
map:
publish: 1
uid:
plugin: migration
migration: wp_wordpress_wordpress_authors
source: creator
body/format:
plugin: default_value
default_value: basic_html
type:
plugin: default_value
default_value: page
path/pathauto:
plugin: default_value
default_value: 0
alias:
-
plugin: get
source: link
-
plugin: str_replace
source: link
search: 'https://myurl.com/'
replace: '/'
destination:
plugin: 'entity:node'
migration_dependencies:
required:
- wp_wordpress_wordpress_authors发布于 2018-06-21 19:39:31
结果发现path/alias成功了。我一定是做错了什么,否则我的页面被缓存,它没有重定向到别名。
path/alias:
-
plugin: get
source: link
-
plugin: str_replace
source: link
search: 'https://myurl.com/'
replace: '/'https://drupal.stackexchange.com/questions/263563
复制相似问题