About Fragments Oracle Fusion Middleware Online Documentation Library

6 Fragments 6-1 6 Fragments This section covers the following topics: ■ Section 6.1, About Fragments ■ Section 6.2, Fragment Libraries ■ Section 6.3, Read-Only Fragment Libraries ■ Section 6.5, Fragment Snippets and the ssIncludeXml ■ Section 6.6, Fragments That Use Custom Section Properties ■ Section 6.7, The Fragment Definition File ■ Section 6.8, Fragment Instance Structure in the ssinfo XML Data Island

6.1 About Fragments

A fragment is a self-contained snippet of HTML or script including client-side JavaScript and server-side Idoc that may have value in being reused in more than one template on a web site. A fragment may contain references to other files, too, with tags like IMG SRC=xxx, SCRIPT SRC=xxx, and docLoadResourcexxx . Externally referenced files or resources serve as a fragment asset and therefore need to be made available whenever the fragment is used. Simple fragments may contain atomic content that can be inserted anywhere in a template. More complex fragments require some content to be placed in the head of the page and other content to be placed in the body. In the body, content may be placed at the top of the page, the bottom of the page, or at the cursors current position. A fragment, therefore, may contain multiple fragment snippets. While it is possible to include multiple body snippets with a head snippet, this is discouraged. Primarily because fragments that use the head of a page cannot be placed in a region template or a subtemplate. This is because neither region templates nor subtemplates are full HTML pages, and do not contain a head. Fragments should be created using just the body to best fit with the flexible nature of Site Studio architecture. Using just a body would allow the fragment to be used on page templates, subtemplates, and region templates. A page template does contain a head, and fragments can have both a head and body when used in a fragment. However, these fragments will create an ssinfo XML data island. For more information, see Section 6.8, Fragment Instance Structure in the ssinfo XML Data Island. 6-2 Oracle Fusion Middleware Technical Reference Guide for Site Studio The designer may want a fragment to take on a different look and feel or behavior depending on where it is used on the web site. This functionality is made available by the use of fragment parameters. With fragment parameters, the creator of a fragment can specify certain variable parameters, and the site designer can choose from these parameters when the fragment is actually added to a template. From a high level, fragments contain: ■ Zero or more fragment parameter definitions name, type, default value that are referenced in the fragment snippets but declared uniquely on each page that includes the fragment instance. ■ One or more fragment snippets, which are pieces of HTML or script along with an identifier to indicate where that content should be placed when the fragment is added to a template. ■ Zero or more fragment assets, which are the local files referenced by a fragment that will be made available to the fragment when it is used on a web page. It is common for a fragment to consist of two snippets. The first, usually found in the head of the page, may reference a CSS file, which will format the page, or a JavaScript file, which will provide some or all of the fragments implementation. The second, usually found in the body of the page at the drop-point, contains the presentation for the fragment. It may be as simple as a JavaScript call of a method provided by the included .js file, or it may contain a collection of HTML, JavaScript, and Idoc Script.

6.2 Fragment Libraries