Skip Headers
Oracle® Fusion Middleware Managing Oracle WebCenter Content
11g Release 1 (11.1.1)

Part Number E26693-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

36 HTML Snippets

This chapter provides information about HTML snippets and Dynamic Converter, describes how to use snippets, and describes a portal-style Website sample.

This chapter covers the following topics:

36.1 About HTML Snippets

In earlier versions of Dynamic Converter (prior to version 6.0) and Oracle WebCenter Content Server, a content item could be checked in, dynamically converted to HTML, and displayed as a web page, by itself, to the user. For the purposes of turning a native business document into a web-viewable version (for everyone to see), the solution was there. However, if you wanted to combine information from numerous source content items onto one web page (perhaps marketing information from one document, press releases from another document, or client feedback from a form) you would need to manually create such a document and convert it to a web page. There was no method for combining multiple content items and displaying them on the same web page.

Dynamic Converter now resolves this problem and, as a result, allows you to create powerful, information-rich web pages for your users. With the current version templates and the new Idoc Script function, you can now pull dynamically converted material from multiple content items or even portions of those content items and display them back to the user as a single web page (combined HTML snippets). Furthermore, you can specify a particular version, template, and layout file for each of the included content items.

The result is a portal-style website (see Section 36.2) that draws dynamically generated content from any number of sources.

36.2 Portal-Style Website Sample

The illustration below demonstrates a simple portal-style web page that wraps a Content Server environment (borders and navigation) around four pieces of dynamically converted content. Each piece of content is actually a document checked into Content Server. There are many pieces coming together "on the fly," but to the user, it is a single and seamless web page.

Figure 36-1 Portal-Style Web Page with Html Snippets

Sample portal-style web page with HTML snippets

To create a page like this or a similar one where you are combining HTML snippets of code, you need to customize the dynamic conversion of your content items so that they can be displayed on the same web page. You do this by creating a template or layout file that will strip the TOP, HEAD, and BODY tags out of the dynamically converted HTML file (see step 1 in Section 36.3).

Then use the new Idoc Script function to call your HTML snippets by content ID, version, template, and layout. All of this can be specified in the following Idoc Script tag:

<$incDynamicConversion(Content ID, revisionselectionmethod, template, layout)$>

36.3 Combining HTML Snippets Into a Web Page

To combine your HTML snippets into a single web page:

  1. Generate a snippet of HTML from a content item (see Section 36.3.1).

  2. Call the snippet of HTML into the host page (HCST file) using Idoc Script (see Section 36.3.2).

36.3.1 Generating a Snippet of HTML

You can generate a snippet of HTML from a content item using either of two methods:

  1. Making the conversion template XML-compliant

  2. Create a layout template with body content only

Method 1: Make the Conversion Template XML-Compliant

By making your template XML-compliant, you remove the standard HTML tags that are placed at the beginning and end of a web page (<HTML>, <HEAD>, <BODY>, etc.). To create an XML-compliant Classic HTML Conversion template:

  1. Open the Dynamic Converter Admin page.

  2. Click Edit Template.

  3. On the Edit Templates page, enter the content ID for the desired template in the Template text box or select your desired template from the Available Templates menu.

  4. Click Edit Template.

    (Instead of updating an existing Classic HTML Conversion template, you may want to create a new template designed specifically for HTML snippets.

  5. In the Template Editor, click Globals.

  6. In the Globals dialog, click the Options tab.

  7. Select the Generate XML compliant output checkbox to enable this Element.

  8. Click OK to close the Globals dialog and click OK again to close the Template Editor.

Your conversion template will now create the required HTML code from a content item so that it can be easily included in a separate web page (using an Idoc Script function; see Section 36.3.2).

Method 2: Create a Layout Template with Body Content Only

Another way to remove the standard HTML tags that are placed at the beginning and end of a web page (<HTML>, <HEAD>, <BODY>, etc.) is to specify a layout template that places only the contents of the BODY tag in your converted HTML file. You can accomplish this by placing the following code (called a token), by itself, in a layout template:

<!-- TRANSIT - CUSTOMLAYOUT(BODY) -->

You can also use the sample layout template "snippet_layout.txt" (see Section 34.4.2), which contains the necessary code. This file is located is available for download from Oracle Technology Network at http://www.oracle.com/technetwork/indexes/samplecode/.

Whether you choose to create a Classic HTML Conversion template or layout template for the purpose of HTML snippets, it is not necessary to associate either template with your content items. You can specify the appropriate template to use with an Idoc Script function; see Section 36.3.2).

36.3.2 Include HTML Snippet Using Idoc Script Function

After you have created your snippets of HTML from your content items (see Section 36.3.1), you are ready to reference the content items from another web page. The way to do this is to use the following Idoc Script function in an HCST file:

<$incDynamicConversion(Content ID, revisionselectionmethod, template, layout)$>

This Idoc Script function references your content items by content ID, version, template, and layout (layout template). For example, if you want to include the latest version of a "Sales" document using the "Business" Classic HTML Conversion template and "snippet_layout" layout template into your web page, you would use the following code:

<$incDynamicConversion("Sales","latest","Business","snippet_layout")$>

If you used an XML-compliant template to create an HTML snippet of code from a content item (see Method 1: Make the Conversion Template XML-Compliant), then you do not need to specify a layout template that creates the same HTML snippet effect. You can, instead, pass a blank parameter in the Idoc Script function: <$incDynamicConversion("Sales","latest","Business","")$>.

For your convenience, a sample layout template called "snippet_layout.txt" (see Section 34.4.2), is available for download from Oracle Technology Network at http://www.oracle.com/technetwork/indexes/samplecode/. This sample file includes the basic ingredients for a portal-style web page that draws information (HTML snippets) from other content items stored in the Content Server. (The results appear very similar to the illustration in Portal-Style Website Sample).

The file contains the following parts:

  • Header and footer information that displays Content Server borders and navigation

  • HTML tables to control the layout of the portal page (two columns in the top table cell and one column in the bottom)

  • Three Idoc Script functions to pull three separate pieces of content into the portal page (referencing a version, template, and layout file in each)

You can start with this portal web page example and then customize it to fit your needs.

36.4 Inline Dynamic Conversion

Dynamic Converter includes an Idoc Script extension that allows you to convert a native document into an HTML snippet without referencing a Classic HTML Conversion template or layout template. The conversion is the same as using a blank Classic HTML Conversion template with a layout template that specifies body content only. (You cannot, however, modify the conversion template or layout template used in this conversion.)

You can convert native documents this way by using the following Idoc Script code:

incInlineDynamicConversion(dDocName, Revision_Selection_Method)

Place the content ID of the native document in the parenthesis along with the revision. For example, if the native document has the content ID "SalesDoc," then the complete Idoc Script syntax would be:

<$incInlineDynamicConversion("SalesDoc", "Latest")$>

or

<$incInlineDynamicConversion("SalesDoc", "LatestReleased")$>

This type of conversion is useful for converting native documents into HTML snippets without having to specify a Classic HTML Conversion template and a layout template in the Content Server.

36.5 Displaying Content Server Metadata on a Web Page

Dynamic Converter includes an Idoc Script extension that allows you to make Content Server metadata for a document available on the converted page. To use this Element, insert the following code into your conversion template:

dcLoadDocInfo()

You can add this code to a layout template (see Chapter 34, "Classic HTML Conversion Layout Templates") or a Classic HTML Conversion template (see Chapter 33, "HTML Conversion Templates"), depending on how you are using these templates for your document conversion. It is important that this code be placed before any part of the web page attempts to use the document metadata.

The simplest solution is to add it to the very top of a layout template. This way, any part of the web page that tries to use the Content Server metadata for the document will work. You can also add this code to any of the sections of a Classic HTML Conversion template (for more information, see "Including HTML or scripting code in a web page" in the Template Editor help).