6-4 Oracle Fusion Middleware Technical Reference Guide for Site Studio
Code Example --wcmFragmentfragmentInstanceID, fragmentDocName, fragmentID,
snippetID, ssTheme=default, ssHoverColor=, ssTextColor=, ssFocusColor=, ssShowHome=true, ssShowNext=false, ssClassName=IDocNavTabsTop--
6.5 Fragment Snippets and the ssIncludeXml
Each fragment contains a snippet defined by the fragment definition file for the fragment library. A fragment snippet can be included in a fragment in one of three
ways:
■
simple : the fragment snippet is added directly to the layout page with no
additional markup and is no longer recognized or managed as a fragment.
■
inline : the fragment snippet is added directly to the layout page but with special
markup surrounding it so that it can be recognized and managed as a fragment.
■
reference : the fragment snippet is not actually added to the layout page; rather, a
reference to the snippet is added much like an include file along with surrounding markup so that it can be recognized and managed as a fragment.
It is highly recommended that you use reference as the include mechanism for all but the most trivial of snippets. This way you can manage the snippet content in a single
place even if the fragment is used many times across the site.
The exact syntax for the special markup surrounding inline and reference snippets can be found in
Section 9.14, ssIncludeXml. For snippets included by reference, the
snippet is added to the layout page using a script extension called ssIncludeXml. This script extension provides an Idoc mechanism for including elements from a
managed XML file and placing them in a layout page. The parameters for the ssIncludeXml include the dDocName of the fragment definition file of the fragment
library and an XPath expression for the XML node to be extracted. More parameters are explained in
Section 9.14, ssIncludeXml . The content of the XML node extracted
is further evaluated in the scope of the current template and therefore can include additional server-side Idoc Script, if necessary.
6.6 Fragments That Use Custom Section Properties
Custom section properties can be defined by the Designer and unique values can be assigned to each property for each section of the web site see the Oracle Fusion
Middleware Users Guide for Site Studio Designer. The definitions and the values are stored in the web site project file.
By themselves, custom section properties are useless. Only when a custom property is referenced by client-side or server-side script within a layout page or more typically,
within a fragment snippet, does it become useful. There are two primary ways to access custom section property values: client-side JavaScript and server-side Idoc
Script.
6.6.1 Client-Side JavaScript
The client-side runtime generated file sitenavigation.js contains an array of NavNode objects containing a definition for the current web site hierarchy See
Section 5.2.1, sitenavigation.js
. Each custom section property that has a value for the current section will be contained within the NavNode object for that section in a member
variable whose name begins with cp_.
Fragments 6-5
The most typical use of these client-side representations of the custom section properties is within navigation fragments. When a navigation fragment is iterating
through the NavNode objects, it can detect the existence of the cp_XXX member variables and use them to customize the navigation scheme being displayed. Since the
cp_XXX member variable may or may not exist, accessing the parameter is made easier through the use of two JavaScript methods provided by Site Studio:
■
customSectionPropertyExists prop : returns true or false to indicate whether the
custom section property exists; if this method returns true, you can use the custom section property directly.
■
getCustomSectionProperty prop : returns the value for the custom section
property, if it exists; returns an empty string otherwise. You can see these two methods in action in the CSP Sample Navigation client
fragment that ships with Site Studio for more information, see the Oracle Fusion Middleware Users Guide for Site Studio Designer.
6.6.2 Server-Side Idoc Script
There are a number of ways to access custom section properties using server-side Idoc Script:
■
ssGetNodePropertyname : this script extension retrieves the value for the named
property for the current web site section.
■
ssGetNodeProperty nodeId, name : this script extension retrieves the value for
the named property for the specified web site section.
■
SS_GET_ALL_NODE_PROPERTIES service: this service retrieves a list of all
custom section properties for the specified web site section. You can see these in action in the CSP Sample Navigation server, CSP Sample
Dynamic List, and Sample CSP Page Title fragments, which ship with Site Studio see Sample fragments in the Oracle Fusion Middleware Users Guide for Site Studio
Designer.
The custom section properties are also stored in the XML rendition of the site hierarchy in the sitenavigation.xml file see
Section 5.2.3, sitenavigation.xml . So if
you are building a navigation fragment that uses server-side script to parse this XML file, you will also have access to the custom section properties for each section.
The name of the property MUST be in quotes. Thus, if you wanted to get the label property of a specific node, you would write:
--label = ssGetNodePropertynodeId, label--
6.7 The Fragment Definition File