WORKING WITH DOCUMENT TYPES OUTSIDE OF UMBRACO

Adding document types can sometimes be time consuming and cumbersome, especially if the document type has a lot of tabs and fields. So, instead of forcing you to re-enter all this information time and time again, Umbraco provides the ability to export existing document types and import them into another installation.

Exporting a Document Type

As shown in Figure 3-11, exporting is an easy three-step process:

  1. Right-click the document type you want to export.
  2. Click Export Document Type.
  3. Save the generated XML file on your computer.

FIGURE 3-11

image

The file type that Umbraco generates is saved with an extension of .udt. You can open this using any text editor like Notepad. You can manually edit the document type by altering the XML in the exported .udt file. However, doing this is not advised because system-generated IDs can get out of sync and duplicated if you are not careful.

You can do a couple of things with your shiny new exported document type. The most obvious is importing it to another installation (see the next section in this chapter) to avoid starting from scratch and retyping all your properties and tabs.

image If you have custom data types defined in a given Umbraco installation and you export your document type for use with another Umbraco installation, you end up with data type IDs that do not exist in the new system. This means that you must select the appropriate data type for those properties that do not utilize standard data types.

The other benefit to exporting document types is the ability to add them to your existing source control and versioning system (such as Subversion, which is an open-source source control system available at http://subversion.tigris.org/). This feature allows you to easily revert to older versions and, more importantly, have an offsite backup in case of a disaster.

Importing a Document Type

You can import a document type from an existing .udt file in a few simple steps, as shown in Figure 3-12.

  1. Right-click the Document Types node, and click the Import Document Type menu item.
  2. In the Import Document Type pop-up dialog, select the file from your computer, as shown in Figure 3-13.
  3. Click the Import button.
  4. In the confirmation dialog, double check that the correct document type was selected from your computer, and click the Import button.

FIGURE 3-12

image

The document type is now ready for you to use and alter as needed.

Exporting Document Types as Plain Old CLR Objects

Exporting document types as Plain Old CLR (common language runtime) Objects is a great feature when you need to interact with content nodes from .NET user controls. Umbraco generates Plain Old CLR Objects, also known as POCOs, with or without abstractions. Exporting document types enables you to quickly bring in this code to your project and start working with the content properties. This process generates objects for all of your document types.

FIGURE 3-13

image

To generate the POCO stub files, follow these instructions:

  1. Rick-click Document Types, and click the Export to .NET menu item.
  2. In the Export to .NET dialog, shown in Figure 3-14, select the Generation Mode you desire.

    FIGURE 3-14

    image

  3. Enter the DataContext value desired. This value is used to create the name of your class followed by DataContext. For example, if you type in Test, the name of your class will be TestDataContext.
  4. Enter the Namespace value desired. The namespace you choose here should match that of your Visual Studio project.
  5. As shown in Figure 3-15, click the POCO download link to save the generated file to your computer. Remember to change the file extension to .cs.

    FIGURE 3-15

    image

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset