Skip to content

进出口-Import Export

ARCHIVED

!注意“归档”

This chapter has not been updated for the current version of Orchard, and has been ARCHIVED.

The definition for content types, as well as the content itself, can be exported from one Orchard instance, and imported into another using this module. The format that is used for the transfer is the same XML format that is used in recipes. The Import/Export module is shipped with Orchard by default but is also available in the gallery.

内容类型的定义以及内容本身可以从一个Orchard实例导出,并使用此模块导入另一个。用于传输的格式与配方中使用的XML格式相同。默认情况下,导入/导出模块随Orchard一起提供,但也可在[gallery](https://gallery.orchardproject.net/List/Modules/Orchard.Module.Orchard.ImportExport“导入/导出模块”)中找到。

Getting Started

入门 ##

The Import/Export module ships with Orchard but it is not enabled by default. So, the first thing to do is enable the module. Once enabled, a new menu item will appear in the admin section.

导入/导出模块随Orchard一起提供,但默认情况下不启用。因此,首先要做的是启用模块。启用后,管理部分中将显示一个新菜单项。

Enable the Import/Export module

Import/Export menu

Export

出口 ##

The export process has two general questions: What type of content should be exported and of that content type, should the meta data and/or the data be output. There is also an option that will include the site's settings in the XML file: site settings to an extent can be automatically exported and imported without module authors writing import/export logic for their site settings content parts. This option is exactly what it sounds like; Any of the information under the settings menu in the admin will be included in the export.

导出过程有两个一般问题:如果要输出元数据和/或数据,应导出哪种类型的内容以及该内容类型。还有一个选项将包括XML文件中的站点设置:可以自动导出和导入范围内的站点设置,而无需模块作者为其站点设置内容部分编写导入/导出逻辑。这个选项正是它听起来的样子;管理员设置菜单下的任何信息都将包含在导出中。

The export process is a good way to copy the content structure from one Orchard instance to another. A good example of that may be from a development site to a production site. For example, let's say we want to create a new blog and add entries to the new blog on a dev site. After all the powers that be have reviewed the blog and it's posts, all that information should then be pushed to the production site. The Import/Export module is perfect for this. But be warned, when exporting from a site and importing to another, the existing records may be updated. We'll get into that in a bit.

导出过程是将内容结构从一个Orchard实例复制到另一个Orchard实例的好方法。一个很好的例子可能是从开发站点到生产站点。例如,假设我们要创建一个新博客,并在开发站点上向新博客添加条目。在审查了博客及其帖子的所有权力之后,所有这些信息都应该被推送到生产站点。导入/导出模块非常适合这种情况。但请注意,从站点导出并导入到另一个站点时,可能会更新现有记录。我们稍后会介绍一下。

Another example would be when creating a new content type on a dev site or local development machine and that new content type needs to be added to another instance of Orchard (or vise-verse). One such situation could be where an account team member is ready to start entering copy but the site is not ready. In this case an empty version of Orchard could be created for them to enter content while the developer is still working on the site. The developer would know what type of information needs to be entered ahead of time and can create the part on his/her development machine and export that content type to the dev site for the other team members to begin entering copy. So while the developer is working on the main site, other team members are entering the copy in a different instance of Orchard. Once the account team has entered all their copy, that information can be exported and imported into the proper instance of Orchard.

另一个例子是在开发站点或本地开发机器上创建新内容类型,并且需要将新内容类型添加到另一个Orchard实例(或vise-verse)。其中一种情况可能是帐户团队成员准备开始输入副本但网站尚未就绪。在这种情况下,可以创建一个空版本的Orchard,供开发人员在网站上工作时输入内容。开发人员将知道需要提前输入什么类型的信息,并且可以在他/她的开发机器上创建该部件并将该内容类型导出到开发站点以供其他团队成员开始输入副本。因此,当开发人员在主站点上工作时,其他团队成员正在另一个Orchard实例中输入副本。一旦帐户团队输入了所有副本,就可以导出该信息并将其导入到Orchard的正确实例中。

The export can also be used as a poor man's backup as well. Simply exporting the data will provide a small XML file that can be kept in a safe location.

出口也可以用作穷人的备份。简单地导出数据将提供一个可以保存在安全位置的小型XML文件。

When Existing Content is Updated

更新现有内容时###

The export attempts to create individual ID's on each data item that it exports (a data item being a single content type record like a page or a blog post). The ID is used during the import process to find a match on an existing record. This way duplicates are not created and any existing items are updated with changes that have occurred to the data for a particular item. The first way the ID is generated is using the Autoroute part. The ID is further strengthened with the addition of the Identity part. The Identity part automatically generates a unique identity for the content item, which is required in import/export scenarios where one content item references another.

导出尝试在其导出的每个数据项上创建单个ID(数据项是单个内容类型记录,如页面或博客文章)。 在导入过程中使用ID来查找现有记录的匹配。这样就不会创建重复项,并且会使用特定项的数据发生的更改来更新任何现有项。生成ID的第一种方法是使用Autoroute部分。通过添加Identity部分进一步加强了ID。 Identity部分自动为内容项生成唯一标识,这在导入/导出方案中是必需的,其中一个内容项引用另一个内容项。

If a Content Type does not have the Autoroute part or the Identity part no ID is given, Orchard will try to find a match based on date stamps, otherwise each import will insert the records as if they do not exist.

如果内容类型没有Autoroute部分或Identity部分没有给出ID,Orchard将尝试根据日期戳找到匹配,否则每次导入都会插入记录,就好像它们不存在一样。

Import

导入##

The import process is quite simple. In the import tab, select the XML file to be imported and click the Import button. Orchard begins to process the file by first looking for metadata that contains any new content types or changes to existing content types and processes those. It then looks for any data that has been included and processes that.

导入过程非常简单。在导入选项卡中,选择要导入的XML文件,然后单击导入按钮。 Orchard开始处理该文件,首先查找包含任何新内容类型的元数据或对现有内容类型的更改并对其进行处理。然后,它会查找已包含的任何数据并对其进行处理。

If there are any site settings included in the XML file those are also processed and applied.

如果XML文件中包含任何站点设置,则还会处理和应用这些设置。