This post focuses on page development best practices that developers can leverage in their Oracle Site Studio environments. This post is part of a blog series exploring best practices to consider when planning for and building a Site Studio website. Unlike my Getting Started with Site Studio post, for this series, I’m assuming you’re already working and fairly familiar with Site Studio - which is part of the Oracle WebCenter Content (WCC) offering.
Reuse Site Assets When Possible
The Site Studio architecture is built for site asset reuse. Content items should be reused when possible, which can allow for simplified development and maintenance.
For example, if you have a Plaintext Element whose functionality is the same across multiple websites, then you could create a generic Plaintext Element and reference that single element from all of the sites instead of creating site-specific versions of it.
Another example where site asset reuse can be used is for Page Templates. It is typically a good practice to keep the number of Page Templates as low as possible, and you can do so by having a main Page Template that references a Placeholder, which in turn would have a listing of Subtemplates that can be used based on the site section. Each Subtemplate would then have its own Placeholder, thereby allowing you to control the assigning of Contributor Data Files to contribution regions based on the site section.
For example:
- Assume a site has 1 Page Template with a Content ID of COMMON_PAGE_TEMPLATE
- Assume that there are 5 main sections to the site, where 4 of those site sections (Products, Services, Downloads, and Documentation) can share the same template and the remaining site section (About) would require its own unique template
- Therefore, you could create 2 Subtemplates (one to be shared by 4 of the sections, and one unique to the remaining section): COMMON_SUBTEMPLATE and ABOUT_SUBTEMPLATE
- You could then have 2 Placeholder Definitions: COMMON_PLACEHOLDER and MAIN_CONTENT_PLACEHOLDER.
- For the COMMON_PLACEHOLDER, you would assign it the 2 Subtemplates, reference that Placeholder from the COMMON_PAGE_TEMPLATE (e.g., via the wcmPlaceholder tag), and then choose which Subtemplate to assign based on the site section
- As for the remaining MAIN_CONTENT_PLACEHOLDER, you would reference that Placeholder from the 2 Subtemplates and associate a Contributor Data File to it based on the site section
- You could then create your Region Definitions and corresponding Region Templates and assign all of them to the MAIN_CONTENT_PLACEHOLDER (note that Site Studio will know which Region Template to use to draw out the page snippet because each Contributor Data File is tagged with an xRegionDefinition metadata value, which it would find under the MAIN_CONTENT_PLACEHOLDER, which would then in turn map to the appropriate Region Template)
Use Fragments for Reusable Chunks of Code
Site Studio Fragments are a great place to store reusable code that can then be referenced from your templates.
For example:
- It is common to create a Header Fragment that stores common CSS and JavaScript includes, which can then be referenced in the <HEAD> section of your Page Template
- You can also have a common Navigation Fragment that can be placed near the top of the <BODY> section
- And a Footer Fragment that can be placed right before the ending </BODY> tag of the Page Template
This allows you to make a central change to a Fragment and have that change seen by every page based on the template that references it.
For more info, refer to the following post: Oracle WCC - Site Studio Fragment Best Practices for Developers.
XHTML Compliance
If your webpages need to be XHTML compliant, potential XHTML validation errors and corresponding solutions are listed below for your Site Studio Page Templates:
- Validation Error: Missing xmlns attribute for element html
Solution: Add the following attribute to the <html> tag:
xmlns="http://www.w3.org/1999/xhtml"
- Validation Error: there is no attribute "warning"
Solution: Delete the warning attribute from the <ssinfo> tag
- Validation Error: element "ssinfo" undefined
Solution: Wrap the <ssinfo> tag with a CDATA tag:
<script id=”ssinfo” type=”text/xml”>
<![CDATA[
<ssinfo> ……… </ssinfo>
]]>
</script>
Dynamic Conversion of Documents
It is typically recommended to use the Contributor application where contributors can edit Elements that make up regions of the page. While it is possible to instead setup a dynamic conversion to HTML of a document (such as a Microsoft Word doc) for part of a page via the Dynamic Converter feature of WCC, I have generally avoided it.
Dynamic Conversions of documents can be cumbersome, and the creators of the documents have to adhere to a specific document template so that the mapping over to HTML can occur successfully. Whereas the Contributor application allows for a quick preview of your changes before you save them, you would instead have to check in a document and then visit the webpage to see if the document was converted properly to HTML for the page.
However, if your contributors are more comfortable using current applications such as Word to author their content, then Dynamic Converter may be preferred.
Element Actions for Contributors
Depending on the group of contributors that will be using the Contributor application, you may wish to either open up as much control over the Elements as possible, or restrict as many actions as possible.
The less technically advanced the contributor or the stricter the styling guidelines of the site, the more you may wish to restrict as many Element actions as possible so that more of the styling and code can be controlled in the background (for example, disabling the use of Tables in a WYSIWYG Element if you do not want contributors to use HTML tables for layout purposes).
Figure A-41 of Oracle's User's Guide for Site Studio Designer
On the other hand, the more technically advanced the user or the less strict the styling guidelines of the site, the more you may wish to open up many of the Element actions that the contributor will have control over.
Element to Region Definition Associations
It is possible to directly embed an Element Definition within a Region Definition via the “Embed the element definition inside the region definition” check box when adding an Element to a Region Definition. However, it is generally recommended to not do so. Instead, create all Element Definitions as separately managed pieces of content.
While an Element may seem to only apply to one particular Region Definition at the moment, it is possible that in the future the Element could be reused. Also, it can get quite cumbersome from Site Studio Designer to get to the Element, since it will take multiple mouse clicks to get to it, especially if it is part of a Static List Element.

Caching
The out-of-the-box "Max Age" and "Max Age Secondary" site section properties can be used to set a max amount of time a primary or secondary page can be cached, which comes in handy when using a reverse proxy to cache your site.
Also, a more granular and programmatic approach to caching can be leveraged by using the Idoc Script function called cacheInclude().
For example, assume you have a Dynamic List element on a page whose query takes a long time to complete. Instead of writing out the code in a template or fragment that executes that element and then writes out the display code, you could instead place that code in a resource include within a custom component. Your template or fragment would then call that resource include via the cacheInclude() function. The system will first check to see if the output display code from that resource include can be grabbed from the cache before it attempts to re-execute that logic (thereby saving the system from always having to execute the Dynamic List element on every request).
It is a good idea to create global Configuration variables to control the length of time you wish the cache to stay active before expiring. You can reference those Configuration variables from the logic in your resource include when passing arguments to the cacheInclude() function.
For more info, refer to section A (Idoc Script Functions and Variables) and part V (Customizing Content Server with Components) of Oracle's Developing with Oracle WebCenter Content guide.
Related posts: