Allow Contributors To Add Fragments To Your UCM Site Studio Pages

frag1.jpg

In honor of Oracle being recognized by Gartner as a leader in their Web Content Management Magic Quadrant last week, I thought I would post a Site Studio tip.

One of the great features that has always been in Site Studio have been Fragments. Fragments are reusable bits of code that can be inserted into layouts and do different things. They could deliver navigation, be a dynamic list of content, image gallery, event calendar, database lookups, and the list goes on and on.

Up until 10gR4, the only way a Fragment could get onto a page was the site designer would need to add them to a layout using Site Studio Designer. This works well in most cases because Fragments typically provide very specific functionality and may have special placement needs. Take navigation fragments for example.

But sometimes it would be very handy for the content contributor in-context of the website be able to add Fragments themselves. In Site Studio 10gR4, that's very much possible now.
Two of the new objects that allow us to do that are Region Templates and Subtemplates. Region Templates are generally used as the display logic for content coming from a Region Definition. For instance, perhaps my Region Definition defines a Title element and Abstract element. My Region Template would then define how those elements get displayed. Perhaps within <div> tags or maybe in a table. But beyond adding elements in the template, you can also add Fragments! When you do, it will ask you for any parameter settings and then lay down the new function which calls the Fragment.


<!--$wcmFragment("wcm", "SS_FRAGMENTS_EXAMPLES", "RandomConversion", "1", 
"ssQueryText=xWebsiteObjectType <matches> `Native Document`",
"ssTemplate=", "ssLayout=", "ssLimitScope=true")-->

Now when users add content to the site that would use this Region Template, the Fragment comes along with it for display. You can get creative and even have the Region Definition elements drive the parameters of the Fragment.


<!--$wcmFragment("wcm", "SS_FRAGMENTS_EXAMPLES", "RandomConversion", "1", 
"ssQueryText=" & wcmElement("QueryElement"), "ssTemplate=" & wcmElement("TemplateElement"),
"ssLayout=" & wcmElement("LayoutElement") & ", "ssLimitScope=" & wcmElement("LimitScopeElement"))-->

One thing to note is that these functions only include one snippet from the Fragment, the one defined for drop-point. This is identified by the 4th parameter in the function (in this case "1"). In some cases, Fragments may include other snippets with JavaScript or styles. In those cases, you would either need to include those snippets by specifying the function with the appropriate snippet name along with the drop-point snippet. Or you would need to make that JavaScript and styles available in the overall layout.



With Region Templates, a content item (data file defined with the appropriate Region Definition) must be defined. But perhaps you want the user to place a Fragment on the page, but you don't need/want a content item to go with it. You simply want just the Fragment itself. For that, you can use Subtemplates. Subtemplates are what I like to think of as 'mini' layouts. They act like a layout in that you can place multiple placeholder/regions within them along with any surrounding HTML code. They are then including into pages through a placeholder on the true primary or secondary layout. Because they are not associated with data files themselves, they can be placed onto pages independently. So now you can create a Subtemplate and simply insert the Fragment just like the Region Template. Once you make that Subtemplate available in the Placeholder Definition, users can click Assign Content on their page and simply pick that Subtemplate. Now they've just inserted a Fragment on the page themselves!

Update - 8/19/09


In my example code above that uses the elements to drive the parameters of the fragment, I failed to note that those variables would have been assigned earlier in the code using the
<!--$wcmElement("Element Name")-->
function. So I've updated the example to call that function right inline of the wcmFragment function.


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Kyle Hatlestad is a Solution Architect in the WebCenter Architecture group (A-Team) who works with WebCenter Content and other products in the WebCenter & Fusion Middleware portfolios. The WebCenter A-Team blog can be found at: https://blogs.oracle.com/ ateam_webcenter/

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today